How to cancel current request in interceptor - Angular 4

后端 未结 7 1942
情书的邮戳
情书的邮戳 2021-02-05 01:29

As you know it\'s possible to use Interceptors in new versions of Angular 4.

In mine, I want to cancel a request in interceptor in some conditions. So i

7条回答
  •  遇见更好的自我
    2021-02-05 02:13

    @RVP's code will work, We can do one more thing for same.

    add return only, it will also work

        intercept(req: HttpRequest, next: HttpHandler): Observable> {
              if(helper.isTokenExpired(tokenVal)){
                  return;
              }
            .
            . <{code}>
            .
    
        }
    

提交回复
热议问题