简体   繁体   中英

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:

{ "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.

How do I get to these details?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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