我正在使用Angular 2并在使用可观察的Property '_body' does not exist on type 'Response'
时出现此错误。代码如下属性'_body'在类型'响应'上不存在
this.securitiesService.getMarketMovers()
.subscribe(data => {
console.log(JSON.parse(data._body))
});
的getMarketMovers功能很简单:
getMarketMovers() {
return this._http.get('...url address...')
}
我已经尝试设置data
键入any
但那不是为我工作。代码的作品,肯定有一个_body
财产的数据,但它仍然会抛出错误,我不能生成这个错误。
任何帮助,非常感谢。
显示'getMarketMovers'方法的代码。 – micronyks
尝试'data.json()._ body' – yurzui
您得到运行时错误或编译时错误?听起来像一个编译时错误,所以你必须将该'data'变量转换为正确的类型。或者你的'getMarketMovers'函数应该返回正确的类型! – mxii