From 245cc67f79fff7d19a53546785201d936fe6c798 Mon Sep 17 00:00:00 2001 From: Minsu Kim Date: Wed, 17 Jan 2024 17:23:54 +0900 Subject: [PATCH] fix: remove try-catch block and add check request header --- source/core/Ky.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/core/Ky.ts b/source/core/Ky.ts index f4ac5914..c6dcd9b5 100644 --- a/source/core/Ky.ts +++ b/source/core/Ky.ts @@ -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(); } }