From 2a244f596c4ecb11bdb94fccbe07879529d8238d Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 16 Nov 2020 13:26:46 -0700 Subject: [PATCH] bug: fix some issues with the Error object It was parsing string error bodies, when it should not have. --- esm/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esm/index.js b/esm/index.js index 7f85bb0..3a8a929 100644 --- a/esm/index.js +++ b/esm/index.js @@ -24,7 +24,7 @@ export class GraphQLClient { const { headers, status } = response return { ...responseBody, headers, status } } else { - const errorResponseBody = typeof result === 'string' ? { error: responseBody } : responseBody + const errorResponseBody = typeof responseBody === 'string' ? { error: responseBody } : responseBody let requestBodyObject = requestBody try { @@ -116,7 +116,7 @@ export function generateError ({ errorResponseBody, response, requestBodyObject 'There was an error with the request.' const error = new Error(message) - error.response = { ...errorResponseBody, status: response.status, headers: response.headers } + error.response = { ...errorResponseBody, status: response.status, headers: Object.fromEntries(response.headers.entries()) } error.request = requestBodyObject return error