I've a post request that i'm using inside my angular application. My goal is to check the message inside the error, and according to that retry the request BUT i'd like to retry a certain amount of attempts.
In the beginning i was trying this approach:
public post(url, data) {
this._http.post(url, data).pipe(
retry(3),
catchError((err: HttpErrorResponse) => {
if (err.message === 'something') {
return EMPTY;
}
}),
)
}
But in this case it was retrying to send the failing req without checking the condition inside catchError
.
So i was thinking to use the retryWhen() operator, but here i don't know how to specify the amount of attempts that should be executed