In angular I am new for httpClient and trying to implement a solution to retry a http call when the internet is disconnected ie error status = 0. When 3 failed attempts i would like it throw the original http response error.
Below is what I am trying but it doesn't work. Any ideas?
return this.httpClient.post('https://server.com/logins', data, {headers: headers})
.pipe(retryWhen(errors => errors
.pipe(map((err, index) => {
// Caught Error, throw immediately
if (!err) {
throw err;
}
if (err.status !== 0) {
throw err;
}
// Disconnection error
if (index === 2) {
throw err;
}
return err;
}))
.pipe(delay(1000))))