Adding timeout and retry to fetch

preview_player
Показать описание
In "Adding timeout and retry to fetch" I show a few tips to enhance fetch.

Рекомендации по теме
Комментарии
Автор

I like these tutorial videos! Keep it up!

LOLmomentsandfails
Автор

Hi Fredrik, I am not sure if you intended to show us how the code actually runs in the browser . Would there be a way to see how this could be applied, ie : testing it in a browser or something else ? thanks

orchideirakozesr
Автор

Line 24 seems to be unreachable, Fredrik.

moy
Автор

I'd say RxJS it a great way to handle such scenarios(timeout, retry etc) with simplicity. For example, an equivalent for the above would be:

```
ajax(URL)
.pipe(
retryWhen(
errors$ => errors$.pipe(
map(
(err, idx) => idx + 1 <= count
? err.name !== "AbortError" ? throwError(err) : of(null) // of(null)
: throwError(err)
),
mergeAll(),
)
),
);
```

andreigatej