mtcute/packages/tl/scripts/utils.ts
Alina Sireneva d88bc0ea60
chore: code quality improvements
improved eslint config, fixed linter issues, added husky
2023-06-05 00:30:48 +00:00

15 lines
322 B
TypeScript

export async function fetchRetry(
url: string,
params?: RequestInit,
retries = 5,
): Promise<string> {
while (true) {
try {
return await fetch(url, params).then((i) => i.text())
} catch (e) {
if (!retries--) {
throw e
}
}
}
}