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