物业&#39; json&#39;在类型&#39; HttpResponse <any>&#39;上不存在

时间:2017-11-21 05:11:47

标签: angular httpresponse angular-http

HttpResponse@angular/common/http中的通用类,因此我需要提及一种类型,例如HttpResponse<T>(用数据类型替换&#39; T&#39;)。现在我正在替换旧的角度代码:

.map((res: Response) => res.json());

到此:

.map((res: HttpResponse<any>) => res.json());

不推荐使用类Response整个包@ angular / http已弃用)。但这给我一个错误如下:

Property 'json' does not exist on type 'HttpResponse<any>'.

所以我相信我必须改变类型,但要改变什么?这样写它是否正确?

0 个答案:

没有答案
相关问题