Skip to content

Commit

Permalink
bug: fix some issues with the Error object
Browse files Browse the repository at this point in the history
It was parsing string error bodies, when it should not have.
  • Loading branch information
bcomnes committed Nov 16, 2020
1 parent 700dfdc commit 2a244f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2a244f5

Please sign in to comment.