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
Ici quand j'ai autre chose qu'une 403 ou 401 j'ai un throw pas au gout du loader qui load à l'infinie.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 }) ); }
Comment je pourrais faire?
EDIT
Problème résolu
Je désactive le loader manuellement pas de soucis pour throw après
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 this.spinner.hide(); this.notificationService.showError(new Notification('', `Un problème est survenue.`)); return throwError(error);
Partager