4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-12 18:25:50 +00:00
qortal-ui/qortal-ui-plugins/plugins/utils/getUserNameFromAddress.js

21 lines
541 B
JavaScript
Raw Normal View History

2023-01-03 22:19:13 -05:00
import { Epml } from '../../epml.js';
2023-01-04 13:46:19 -05:00
import { cropAddress } from './cropAddress.js';
2023-01-03 22:19:13 -05:00
const parentEpml = new Epml({ type: 'WINDOW', source: window.parent })
export const getUserNameFromAddress = async (address) => {
try {
const getNames = await parentEpml.request("apiCall", {
type: "api",
url: `/names/address/${address}`,
});
if (Array.isArray(getNames) && getNames.length > 0 ) {
return getNames[0].name;
} else {
2023-01-06 14:13:13 -05:00
return address;
2023-01-03 22:19:13 -05:00
}
} catch (error) {
console.error(error);
}
}