2
如何读取角度2 http请求的catch块中的响应主体。以下是代码,我到目前为止有:如何在http call angular catch中读取catch块中的响应主体2
requeueTask(data): Observable<Response>{
this.setHeaders();
let url = SharedService.requeueTaskApi;
return this._http.put(url, data, {headers: this.headers})
.map((response: Response) => response)
//.do(data => console.log(JSON.stringify(data)))
.catch((error: any, response) => {
console.log(response);
if (error.status < 400 || error.status ===500) {
return Observable.throw(new Error(error.status));
}
})
}
使用error.json() –