Files
CHOMPStation2/tgui/packages/tgui_ch/http.ts
2023-05-23 17:43:01 +02:00

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);
});
});
};