From b3cfd44ab7ea46010235c2adc719336f03399bd6 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Tue, 14 Nov 2023 21:39:54 +0100 Subject: [PATCH] remove string check --- packages/core/src/internal/fetchSource.ts | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/core/src/internal/fetchSource.ts b/packages/core/src/internal/fetchSource.ts index 1bcaeaca97..624ef2fb30 100644 --- a/packages/core/src/internal/fetchSource.ts +++ b/packages/core/src/internal/fetchSource.ts @@ -172,24 +172,16 @@ async function* fetchOperation( } else if (!/text\//i.test(contentType)) { results = parseJSON(response); } else { - if (contentType === 'text/plain') { - const text = await response.text(); - if (text.startsWith('{')) { - try { - results = JSON.parse(text); - if (process.env.NODE_ENV !== 'production') { - console.warn( - `Found response with content-type "text/plain" but it had a valid "application/json" response.` - ); - } - } catch (e) { - throw new Error(text); - } - } else { - throw new Error(text); + const text = await response.text(); + try { + results = JSON.parse(text); + if (process.env.NODE_ENV !== 'production') { + console.warn( + `Found response with content-type "text/plain" but it had a valid "application/json" response.` + ); } - } else { - throw new Error(await response.text()); + } catch (e) { + throw new Error(text); } }