Merge pull request #347 from jdalrymple/343-error-handling

This commit is contained in:
Justin Dalrymple 2019-06-10 16:01:13 -04:00 committed by GitHub
commit 21c91c3408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {};
}