I am using Angular 7 and I have used HTTP Interceptor in my application.
I am not able to track 401 status code in that HTTP Interceptor.
I tried pitting catchError and tap but it gives status 0, I want 401.
My code is here:
return next.handle(request).pipe(tap(event => {
console.log('the ev is :', event);
if (event instanceof HttpResponse) {
this.onEnd();
}
}, err => {
if (err instanceof HttpErrorResponse) {
console.log('the eeeeeee is :', err);
this.onEnd();
// User logged out
if (err.status === 401) {
this.router.navigate(['logout']);
}
}
})).pipe(catchError(error => {
console.log('the ee is :', error);
return Observable.throw(error);
}));
Thanks.
tapis hit when there's an error. Google for it.