I’m using requestConfluence
in my Custom UI app to convert an array of user ids to names. I have the following:
const getNames = (ids) => {
const namesList = ids.map(async (id) => {
const profile = await requestConfluence(
`/wiki/rest/api/user?accountId=${id}`
);
const user = await profile.json();
console.log(user.publicName);
return user.publicName;
});
console.log(namesList);
}
So this should take an array of ids, and for each one it gets the user’s profile information and then returns the publicName
field. This creates an array of names, which I then log to the console.
The line console.log(user.publicName);
correctly prints the public name to the console, but the line console.log(namesList);
prints a promise instead.
I don’t understand why this is happening - can anyone help?