Skip to content

Instantly share code, notes, and snippets.

@mactyr
mactyr / retryWhenThrowsLastError.js
Last active July 6, 2018 23:35
http retryWhen that throws last error when retries are exhausted
let retries = 0;
this.http
.get(this.url)
.retryWhen(error => {
return error
.flatMap((error: any) => {
retries++;
if (retries <= 5 && error.status === 503) {
return Observable.of(error.status).delay(1000)
}