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
Post a Comment