res.json() is a not a function in HttpClient Angular 2

后端 未结 2 673
失恋的感觉
失恋的感觉 2020-12-19 18:15

I was using Angular Http module before and the method res.json() used to work fine. I have recently tried HttpClient but then the

相关标签:
2条回答
  • 2020-12-19 18:45

    Right, that's because new http client by default calls res.json() implicitly and you don't need to that manually yourself. Here is the quote from commit:

    JSON is an assumed default and no longer needs to be explicitly parsed

    See Difference between HTTP and HTTPClient in angular 4? for more details.

    0 讨论(0)
  • 2020-12-19 19:00

    As HttpClient itself adds res.json(), which means it implicitly calls this function due to which, it is worthless to call it explicitly or manually. So there is no need to add this function. Hope this works, thanx...

    0 讨论(0)
提交回复
热议问题