diff --git a/package.json b/package.json index 72f8e04..b69c3df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Miru", - "version": "3.0.3", + "version": "3.0.4", "author": "ThaUnknown_ ", "main": "src/index.js", "homepage": "https://github.com/ThaUnknown/miru#readme", diff --git a/src/renderer/src/modules/anilist.js b/src/renderer/src/modules/anilist.js index 5251fb2..c170c5c 100644 --- a/src/renderer/src/modules/anilist.js +++ b/src/renderer/src/modules/anilist.js @@ -87,18 +87,21 @@ const limit = limiter.wrap(handleRequest) async function handleRequest (opts) { const res = await fetch('https://graphql.anilist.co', opts) + if (!res.ok && res.status === 429) return await limit(opts) let json = null try { json = await res.json() } catch (error) { if (res.ok) printError(error) - if (error.status === 429) return await limit(opts) } - if (!res.ok && json) { - for (const error of json?.errors || []) { - printError(error) + if (!res.ok) { + if (json) { + for (const error of json?.errors || []) { + printError(error) + } + } else { + printError(res) } - if (res.status === 429) return await limit(opts) } return json }