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

Viewed 2727

HttpResponse is a generic class in @angular/common/http, so I need to mention a type e.g. HttpResponse<T> (replace 'T' with data type). Now that I am replacing old angular code from this:

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

to this:

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

as class Response is deprecated (whole package @angular/http is deprecated). But this is giving me an error as below:

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

So I believe I have to change the type, but to what? Moreover, writing it like that is correct or not?

0 Answers
Related