mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-16 05:02:42 +00:00
13 lines
389 B
TypeScript
13 lines
389 B
TypeScript
/**
|
|
* An equivalent to `fetch`, except will automatically retry.
|
|
*/
|
|
export const fetchRetry = (url: string, options?: RequestInit, retryTimer: number = 1000): Promise<Response> => {
|
|
return fetch(url, options).catch(() => {
|
|
return new Promise((resolve) => {
|
|
setTimeout(() => {
|
|
fetchRetry(url, options, retryTimer).then(resolve);
|
|
}, retryTimer);
|
|
});
|
|
});
|
|
};
|