0

I'm kinda new with Rxjs. and what I'm trying to do is call an API 5 times, but return a custom error value to my component if after 5 times the request still fails. But somehow it doesn't reach the catchError.

start(): Observable<any> {
        return this.http.put<any>(`${this.apiConfig}/start`, {})
            .pipe(
                map(res => {
                    return res;
                }),
                retryWhen(errors => errors.pipe(delay(3000), take(4))
                ),
                catchError(() => of({
                    status: "NO_CONNECTION"
                }))
            );
    }

1 Answers1

1

You should properly use retryWhen operator and send error if it's not ok. Chan your code to:

retryWhen(errors => errors.pipe(

delay(3000),

take(4),

concatMap(e => throwError(e))

))
Anton Marinenko
  • 2,749
  • 1
  • 10
  • 16