[英]Angular catchError in RxJS
I am posting data to the server with the following method我使用以下方法将数据发布到服务器
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)
}));
}
The server is returning a 400 error with details:服务器返回 400 错误,详细信息:
{ "errors":[ "Current password does not match" ], "isSuccess":false, "timeStamp":"2020-02-11T13:01:06.975597-05:00", "result":null }
However, all I am seeing inside the catchError
for the e
variable is Bad Request
without any of the details.但是,我在
e
变量的catchError
看到的只是Bad Request
没有任何细节。
How do I get to these details?我如何获得这些详细信息?
console.log('catch error: ', e.error), e.error 对象将有来自服务器的响应
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.