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


i using angular http module before , method res.json() used work fine. have tried httpclient res.json() dosen't seem work . using res works can 1 tell me changed has happened in http client.

return this.client.get('https://swapi.co/api/people/1/')               .map((res:response) => {                  return  res.json(); // using maps filter data returned form http call json dosn't work http client               }).map(data => {                 return data; // using maps of maps filter data returned form map         }).flatmap((jedi) => this.http.get(jedi['homeworld'])           .map(res => {            return res.json().name; // using flat maps combine data returned 2 observables 1           }).catch((error:any) => observable.throw(error.json().error || 'server error'))); 

i switched http client because of new interceptor can pointers welcomed thanks

right, that's because new http client default calls res.json() implicitly , don't need manually yourself. here quote commit:

json assumed default , no longer needs explicitly parsed

see difference between http , httpclient in angular 4? more details.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -