Angular 14 JWT Refresh Token example with Http Interceptor
Implementing Angular 14 Refresh Token before Expiration with Http Interceptor and JWT.
You can take a look at following flow to have an overview of Requests and Responses that Angular 14 Client will make or receive.
instead of class, angular is now moving on to use const for interceptor
the way you mentioning is no longer valid, we'll have to implement the refresh with the new format, e.g.:
export const authInterceptor = (req: HttpRequest, next: HttpHandlerFn): Observable<HttpEvent> => {
return next(newReq).pipe(
catchError((error) => {
// Catch "401 Unauthorized" responses
if (error instanceof HttpErrorResponse && error.status === 401) {
// mergemap refreshtoken call
}
return throwError(error);
}),
);
any idea please?