I'm looking for a possibility to call a catchError repeatingly / recursive for a http call. First I just used retry(x) but now I need to modify the request in case of an error.
Right now the catchError get called only once (for sure). How to modify it?
export class HttpErrorInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
let attempts = 0;
return next.handle(request).pipe(
catchError(e => {
attempts++;
if (attempts < 5) { return next.handle(request.clone({ ...{} })); }
throw e;
})
);
}
}