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>'.
所以我相信我必须改变类型,但要改变什么?这样写它是否正确?