RxJS中的角度catchError

时间:2020-02-11 18:06:56

标签: angular 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 }

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

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

1 个答案:

答案 0 :(得分:0)

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