Skip to content

Commit

Permalink
fix: crude check for disabled anilist api
Browse files Browse the repository at this point in the history
  • Loading branch information
pilar6195 committed Jul 30, 2024
1 parent 5cad090 commit 86dd9f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "anilist-extras",
"version": "2.7.4",
"version": "2.7.5",
"description": "Adds a few additional features to AniList.",
"scripts": {
"build": "bun run build.ts",
Expand Down
9 changes: 9 additions & 0 deletions src/utils/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ export const anilistApi = async (
data: JSON.stringify({ query, variables }),
});

if (response.status === 403) {
const errorMessage = response.json?.errors?.[0]?.message;
if (errorMessage?.includes('disabled')) {
console.error(errorMessage);
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw response;
}
}

// If the request failed and the user has an api token, check if the token is invalid.
if (apiToken && useApiToken && response.status === 400) {
const invalidToken = response.json.errors.some((error: any) => error.message === 'Invalid token');
Expand Down

0 comments on commit 86dd9f1

Please sign in to comment.