我正在通过以下方法将数据发布到服务器
post<T>(url: string, body: T, options?: any): Observable<any> {
return this.http.post<T>(this.path(url), body, options)
.pipe(catchError((e) => {
console.log('catch error: ', e)
return this.formatErrors(e)
}));
}
服务器返回400错误,详细信息:
{
"errors":[
"Current password does not match"
],
"isSuccess":false,
"timeStamp":"2020-02-11T13:01:06.975597-05:00",
"result":null
}
但是,我在catchError
变量中看到的e
只是Bad Request
,没有任何细节。
我如何获得这些详细信息?
答案 0 :(得分:0)
console.log('catch error:',e.error),e.error对象将收到服务器的响应