Skip to content

Only attempt to parse response as JSON if content-type is application/json #100

@chawes13

Description

@chawes13

We should not try to transform responses that we know are not JSON. E.g.,

const fetchTemplate = createRequest('fetchTemplate', () => ({
  url: '/template/contents',
  headers: {
    Accept: 'binary/octet-stream',
  }
})

A workaround does exist for this -- you can pass parseJsonStrictly: false as a configuration option. The response will still be attempted to be parsed as json, but when it fails the response body should be returned as text.

It's possible that for this case we shouldn't try to transform the body at all (even via .text()) so that the client can do whatever they want with it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions