繁体   English   中英

RxJS 中的 Angular catchError

[英]Angular catchError in RxJS

我使用以下方法将数据发布到服务器

  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 }

但是,我在e变量的catchError看到的只是Bad Request没有任何细节。

我如何获得这些详细信息?

console.log('catch error: ', e.error), e.error 对象将有来自服务器的响应

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM