catchError无法与用于模拟错误响应的角度HTTP拦截器一起使用

时间:2019-08-17 11:42:40

标签: angular

我有一个拦截器,将响应模拟为return of(new HttpResponse({ status: 401, body: "Unauthorized" }));

和类似

的服务代码
return this.http.post<string>(queryUrl,{ username, password },{ observe: 'response' })
.pipe(catchError(error =>{
  console.log("!!!!!!error in auth");
  return throwError("!!!!!!error in auth");
}

尽管我期望使用该设置,但未调用catchError方法。是意料之中的吗?

0 个答案:

没有答案