I would like to display username get from async function on profile page. Here is my code to get username on user.js.
//assume username is Peter
async function user_attr() {
try{
const { attributes } = await Auth.currentAuthenticatedUser();
console.log(JSON.stringify(attributes.username)); //output:Peter
} catch (e) {
console.log(e);
}
}
and I would like display it in Text on profile.js.
import './user.js'
<Text>{username}</Text>
Since async function cannot return value, what should I do to display the username?