Angular 11 ng-http-loader loader infinie avec mon interceptor
Bonjour à tous,
Pourriez vous m'aider s'il vous plaît?
J'ai un interceptor qui gère des tokens ça fonctionne parfaitement, j'ai le component http-loader qui affiche un loader pour les requêtes ajax.
Seul soucis les erreurs
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
intercept(request: HttpRequest<any>, next: HttpHandler) {
// add bearer token in header
if (this.authService.getJwtToken()) {
request = this.addToken(request, this.authService.getJwtToken());
}
// resolve request
return next.handle(request).pipe(
catchError((error) => {
console.log(error);
// if permission denied 401 then token is possible expire then call refresh token
if (error instanceof HttpErrorResponse && [401, 403].includes(error.status) && !request.url.includes('authentication_token')) {
return this.handle401Error(request, next);
}
return throwError(error); // le problème est ici
})
);
} |
Ici quand j'ai autre chose qu'une 403 ou 401 j'ai un throw pas au gout du loader qui load à l'infinie.
Comment je pourrais faire?
EDIT
Problème résolu
Je désactive le loader manuellement pas de soucis pour throw après
Code:
1 2 3 4
|
this.spinner.hide();
this.notificationService.showError(new Notification('', `Un problème est survenue.`));
return throwError(error); |