Why do I have to wrap await with () in order to get the output I need. I am hoping to get only the uid from the object
The data that is return from the function that I am importing is exactly how you see it
{uid : 'abcdefg', email:'[email protected]'}
import {ActiveUser} from './teamMembers.service';
export const retrieveList = async date => {
console.log('active user information here', (await ActiveUser()).uid);
// outputs: Works as expected
// active user information here abcdefg
console.log('active user information here', await ActiveUser().uid);
// outputs:
//Undefined
console.log('active user information here', typeof (await ActiveUser()));
// outputs:
// object
}
ActiveUserwould be returning a promise so u needawaitto wait till it executes and returns your Object. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… . await keyword is used for the function call, hence you need the braces and then you access the key of the object.await (ActiveUser().uid). Remember PleaseExcuseMyDearAuntSally? developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…