Skip to content

Commit

Permalink
fix: Handle edge cases where content-type headers are missing or the …
Browse files Browse the repository at this point in the history
…content text is null

fixes: #343
  • Loading branch information
jdalrymple committed Jun 10, 2019
1 parent a54a6ae commit dabcb3d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/infrastructure/KyRequester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ function defaultRequest(service: any, { body, query, sudo, method }) {
}

async function processBody(response) {
const contentType = response.headers.get('content-type');
const contentType = response.headers.get('content-type') || '';
const content = await response.text();

if(contentType.includes('json')) {
try {
return JSON.parse(content || {});
return JSON.parse(content || "{}");
} catch {
return {};
}
Expand Down

0 comments on commit dabcb3d

Please sign in to comment.