Skip to content

Commit

Permalink
Merge pull request #18 from little-core-labs/error-bugs
Browse files Browse the repository at this point in the history
bug: fix some issues with the Error object
  • Loading branch information
bcomnes authored Nov 16, 2020
2 parents 700dfdc + 2a244f5 commit 2967dbc
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 2967dbc

Please sign in to comment.