Skip to content

Commit

Permalink
remove string check
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Nov 14, 2023
1 parent 0eab814 commit b3cfd44
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions packages/core/src/internal/fetchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b3cfd44

Please sign in to comment.