mtcute/packages/tl/scripts/utils.ts
teidesu ec736f8590 some changes
i've been wanting to name a commit like this for my entire life, lol. seriously though, a lot has changed:
 - extracted TL-related stuff to `@mtcute/tl-utils` and `@mtcute/tl-runtime`, rewrote codegen in TS
 - updated to layer 134, moved to int64 identifiers
 - rewritten networking (mtproto), rewritten updates handling
 - *lots* of refactoring

 still a very early version though, there are a lot of improvements to be made, but at least it runs, lol

 also tl-reference will not be updated anytime soon because i want to rewrite it
2021-11-23 00:03:59 +03:00

17 lines
370 B
TypeScript

import fetch, { RequestInit } from 'node-fetch'
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
}
}
}
}