aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-04-16 13:21:53 -0500
committermat <27899617+mat-1@users.noreply.github.com>2021-04-16 13:21:53 -0500
commita7376adb681bd6821f9af6fc6e56f734fcc5c2e7 (patch)
tree52c528dc175692f0f39258023ef68d4dff11631f
parenta89768c346be4c05d20f97c6caf0603d5f352b22 (diff)
downloadskyblock-api-a7376adb681bd6821f9af6fc6e56f734fcc5c2e7.tar.gz
skyblock-api-a7376adb681bd6821f9af6fc6e56f734fcc5c2e7.tar.bz2
skyblock-api-a7376adb681bd6821f9af6fc6e56f734fcc5c2e7.zip
fix error that happens sometimes
-rw-r--r--src/hypixelApi.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts
index f072d11..ee63155 100644
--- a/src/hypixelApi.ts
+++ b/src/hypixelApi.ts
@@ -137,12 +137,14 @@ export async function sendApiRequest({ path, key, args }): Promise<HypixelRespon
const fetchUrl = baseHypixelAPI + '/' + path + '?' + jsonToQuery(args)
let fetchResponse: nodeFetch.Response
+ let fetchJsonParsed: any
try {
fetchResponse = await fetch(
fetchUrl,
{ agent: () => httpsAgent }
)
+ fetchJsonParsed = await fetchResponse.json()
} catch {
// if there's an error, wait a second and try again
await new Promise((resolve) => setTimeout(resolve, 1000))
@@ -157,7 +159,6 @@ export async function sendApiRequest({ path, key, args }): Promise<HypixelRespon
reset: Date.now() + parseInt(fetchResponse.headers['ratelimit-reset']) * 1000
}
- const fetchJsonParsed = await fetchResponse.json()
if (fetchJsonParsed.throttle) {
if (apiKeyUsage[key])
apiKeyUsage[key].remaining = 0