【发布时间】:2019-08-27 20:34:03
【问题描述】:
我真的不知道如何问这个问题或发生了什么。
我正在执行 API 调用来获取数据,如下所示:
getSingleGroupStats(uuid:string, req:any){
return this.http.get(`${this.resourceUrl}/${uuid}/endpoint`, {
params: req,
observe: 'response',
})
}
我所有的 API 调用都是这样的。现在,在我的组件中记录数据主体时,我得到了这个非常奇怪的响应:
所以我的数组中似乎有 2 个对象,但是在扩展数组时...没有数据。
在浏览器的网络选项卡上查看时,数组中实际上有数据。所以我不知道发生了什么。这会导致如下错误:
cannot read property whatever of undefined
因为组件看不到数据。
我不知道该做什么或发生了什么。
编辑
我实际上是在我的组件中订阅响应,如下所示:
this.service.getSingleGroupStats('1234', {}).subscribe(
(res:HttpResponse<any>) => {
console.log('single stats -> ', res.body)
}
)
这个console.log 是所有数据不稳定的地方。
【问题讨论】:
标签: angular