Export value [object Promise] use angular 8?

99封情书 提交于 2020-06-17 09:15:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!