I am trying to return a value from two async functions. I am trying the method used in this thread. Using await outside of an async function
However, I am always getting an undefined value.
common.loggedInUserisAdmin().then((currentUser) => {
console.log(currentUser); // This line is executed before values return from loggedInUserisAdmin function.
});
// Here is my async functions code.
async loggedInUserisAdmin() {
(async () => {
await
this.getCurrentAccount().then().then((currentUser) => {
this.getUserDetailsByEmail(currentUser.userName).then((userData) => {
return userData.admin;
})
})
})();
},
async getCurrentAccount() {
return await msalApp.getAccount();
},
async getUserDetailsByEmail() {
const dataUrl = `$https://localhost:12345/User/GetUserDetails?emailAddress=${emailAddress}`
const errorMessage = 'Error getting current user'
return await authorisedFetch(dataUrl, errorMessage)
}