Skip to content

Commit

Permalink
fix: remove try-catch block and add check request header
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn2468 committed Jan 17, 2024
1 parent b45633c commit 245cc67
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions source/core/Ky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ export class Ky {
return options.parseJson(await response.text());
}

// If error causes when call JSON.parse
try {
return (await response.json());
} catch {
if (response.headers.get('accept')?.startsWith('text')) {
return response.text();
}
}
Expand Down

0 comments on commit 245cc67

Please sign in to comment.