From dabcb3d0aca5f45ad0f7cc35f15f9854af95610b Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 10 Jun 2019 15:38:31 -0400 Subject: [PATCH] fix: Handle edge cases where content-type headers are missing or the content text is null fixes: #343 --- src/infrastructure/KyRequester.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/infrastructure/KyRequester.ts b/src/infrastructure/KyRequester.ts index 27e472d7b..cadcfdbde 100644 --- a/src/infrastructure/KyRequester.ts +++ b/src/infrastructure/KyRequester.ts @@ -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 {}; }