【发布时间】:2019-04-19 18:57:34
【问题描述】:
试图弄清楚为什么这不起作用以及我缺少什么。
我正在从登录页面调用服务中的函数
this.comms.updateAccessedState();
内部服务
async updateAccessedState() {
console.log("get this token 1");
await this.getToken();
console.log(`3 ${this.token}`);
}
和
getToken() {
this._currentUser.getProfile().then((data) => {
console.log("retrieve token 2");
this.token = data.token;
});
将其打印到控制台时
我收到get token => 1
3 undefined
retrieving token => 2
为什么函数没有被“等待”
【问题讨论】:
标签: angular ionic-framework async-await