【发布时间】:2018-01-28 13:10:50
【问题描述】:
我之前使用过 Angular Http 模块,而 res.json() 方法曾经可以正常工作。
我最近尝试过HttpClient,但后来res.json() 似乎不起作用。只有使用res 才能有人告诉我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')));
由于新的拦截器,我切换到http客户端,欢迎使用指针,谢谢
【问题讨论】:
标签: angular angular-http angular-http-interceptors