【发布时间】:2021-02-20 11:09:47
【问题描述】:
在我的 angular ionic 项目中,当我登录第一页时出现错误“错误错误:未捕获(承诺中):TypeError:无法读取属性 'subscribe' of null”但是当我重新加载页面时,我没有'没有错误,我有数据。谢谢
(await this.pageService.getAllTables()).subscribe((res: any) => {
this.tables = res.body
});
}```
```getAllTables() {
this.storage.get('USER').then(user =>{this.user = user;});
return this.storage.get('ACCESS_TOKEN').then(token =>{
if (this.user) {
return this.http.get(this.url + 'table/' + this.user.id, {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
}),
observe: 'response'
});
}
return null;
});
}```
【问题讨论】:
标签: javascript angular ionic-framework