0

Status of my application is getting wrong. it's getting status 401 with the token_expired error but in the HttpInterceptor it's receiving status 0 without the error (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);
                })
            )
    }

console firefox. enter image description here

Herick
  • 217
  • 1
  • 3
  • 13
  • I also experience this issue during development mode locally but after deploying it on the server, it gets auto fixed and getting the correct status code. so try to test after deploying on server. – Farhat Zaman Dec 18 '18 at 11:55
  • 1
    https://github.com/angular/angular/issues/20991 – Florian Dec 18 '18 at 12:13

0 Answers0