问题
My code
async loginStatus() {
return new Promise((resolve) => {
firebase.auth().onAuthStateChanged(firebaseUser => resolve(firebaseUser))
})
}
async checkLoginStatus(){
const userObject = await this.loginStatus()
return userObject
}
How export value don't use this syntax
this.checkLoginStatus().then(e => console.log(e));
or how save value in a variable .
output if not this syntax => checkLoginStatus[object Promise]
回答1:
make your method async. lets say you was doing it in a method name storeValue(). Do it like :-
async storeValue() {
const output = await this.checkLoginStatus();
}
来源:https://stackoverflow.com/questions/62408873/export-value-object-promise-use-angular-8