diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-04-16 13:14:01 -0500 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-04-16 13:14:01 -0500 |
commit | a89768c346be4c05d20f97c6caf0603d5f352b22 (patch) | |
tree | 6d054f8710c90050ffb550d0498fa0b78bfc244e /src/hypixelApi.ts | |
parent | 4df533fb8cca04c38cd44debb118fef569bcb7c0 (diff) | |
download | skyblock-api-a89768c346be4c05d20f97c6caf0603d5f352b22.tar.gz skyblock-api-a89768c346be4c05d20f97c6caf0603d5f352b22.tar.bz2 skyblock-api-a89768c346be4c05d20f97c6caf0603d5f352b22.zip |
retry on throttle
Diffstat (limited to 'src/hypixelApi.ts')
-rw-r--r-- | src/hypixelApi.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts index 9840c79..f072d11 100644 --- a/src/hypixelApi.ts +++ b/src/hypixelApi.ts @@ -161,7 +161,9 @@ export async function sendApiRequest({ path, key, args }): Promise<HypixelRespon if (fetchJsonParsed.throttle) { if (apiKeyUsage[key]) apiKeyUsage[key].remaining = 0 - return { throttled: true } + // if it's throttled, wait 10 seconds and try again + await new Promise((resolve) => setTimeout(resolve, 10000)) + return await sendApiRequest({ path, key, args }) } return fetchJsonParsed } |