I was using Angular Http
module before and the method res.json()
used to work fine.
I have recently tried HttpClient
but then the res.json()
dosen't seem to work . only using res
works can some one tell me what changed has happened in the http client.
return this.client.get('https://swapi.co/api/people/1/')
.map((res:Response) => {
return res.json(); // using maps to filter data returned form the http call this json dosn't work with http client
}).map(data => {
return data; // using maps of maps to filter data returned form the map
}).flatMap((jedi) => this.http.get(jedi['homeworld'])
.map(res => {
return res.json().name; // using flat maps to combine data returned from two observables into one
}).catch((error:any) => Observable.throw(error.json().error || 'Server error')));
I switched to http client because of the new interceptor can pointers are welcomed thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…