HttpInterceptor刷新令牌

时间:2018-12-18 11:52:37

标签: angular jwt refresh-token

我的应用程序状态出错。 它的状态为401,且token_expired错误 但是在HttpInterceptor中,它的接收状态为0,而没有错误(token_expired)

refresh-token.interceptor.ts

constructor(private injector: Injector) { }

    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

        return next.handle(request)
            .pipe(
                catchError((errorResponse: HttpErrorResponse) => {
                    const error = (typeof errorResponse.error !== 'object') ? JSON.parse(errorResponse.error) : errorResponse.error;
                    console.log("Status: "+errorResponse.status);
                    console.log(error.error);
                    if (errorResponse.status === 401 && error.error === 'token_expired') {

                    }
                    return throwError(errorResponse);
                })
            )
    }

控制台Firefox。 enter image description here

0 个答案:

没有答案