После прочтения документации по angular об обработке ошибок HTTP-клиента я до сих пор не понимаю, почему я не улавливаю ошибку 401 с сервера с помощью следующего кода:
export class interceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log('this log is printed on the console!');
return next.handle(request).do(() => (err: any) => {
console.log('this log isn't');
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
console.log('nor this one!');
}
}
});
}
}
в журнале консоли я также получаю следующее:
zone.js: 2969 ПОЛУЧИТЬ http://localhost:8080/test 401 ()
core.js: 1449 ERROR HttpErrorResponse {заголовки: HttpHeaders, status: 401, statusText: "OK", url: "http://localhost:8080/test ", ok: false,…}