Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chawes13 opened this issue Sep 27, 2021 · 0 comments
Open

Comments

@chawes13
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant