Retry connection when it takes too long

2.9k Views Asked by At

Is it possible in Angular to retry a connection when the calls stays for more then a couple of seconds on pending?

1

There are 1 best solutions below

3
On BEST ANSWER

Should be doable with a combination of pipe, timeout and retry from Rxjs. If timeout is exceeded, retry 4 times, else, catchError.

return this.httpClient.post(url, data, httpOptions).pipe(
  timeout(3000),
  retry(4),
  catchError(<DO SOMETHING>)
);