I am using Angular Service to get data from my API
. I implemented retry feature in case of fetching data fails. Now i need to handle the error when all the retr
please try to change this:
}).pipe(
retryWhen(errors => errors.pipe(delay(1000), take(10), catchError(this.handleError)))
);
to this: This might need a tweak for your own code but this approach works for me, the throwError will be catched as errors
}).pipe(
mergeMap(x => {
if(x == error) return throwError('Error!'); //tweak this for your error
else return of(x);
}),
retryWhen(errors => errors.pipe(delay(1000), take(10))),
catchError(error => this.handleError(error)) // change here
);
and make handle error return observable like:
handleError(err) {
..your code
return of(err); //and NOT return throwError here
}