Skip to content

Commit

Permalink
Refactor REST class to use response.json() for parsing JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
EvarinDev committed Aug 24, 2024
1 parent eec6e4e commit cbc89fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"scripts": {
"build:js": "npx babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline",
"lint": "npx eslint src/**/*.ts",
"test:connect": "bun test/connect.ts",
"test:manager": "bun test/manager.ts",
"test:player": "bun test/player.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion src/structures/Rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class Rest {
},
body: JSON.stringify(body),
});
return JSON.parse(await response.text());
return await response.json();
} catch(error) {
if (error?.response?.status === 404) {
this.node.destroy();
Expand Down
4 changes: 4 additions & 0 deletions test/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ let manager = new Manager({
password: 'youshallnotpass',
},
],
caches: {
enabled: true,
time: 60000,
},
clientId: "1234567890",
send(guild_id, payload) {
const guild = client.guilds.cache.get(guild_id);
Expand Down

0 comments on commit cbc89fb

Please sign in to comment.