res.json () não é uma função no HttpClient Angular 2
Eu estava usando angularHttp
módulo antes e o métodores.json()
costumava funcionar bem. Eu tentei recentementeHttpClient
mas então ores.json()
parece não funcionar. apenas usandores
funciona alguém pode me dizer o que mudou aconteceu no cliente http.
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')));
Eu mudei para o cliente http por causa do novo interceptor, os ponteiros podem ser bem-vindos graças