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

transformResponse catch #110

Closed
richardgregory opened this issue Sep 23, 2015 · 1 comment
Closed

transformResponse catch #110

richardgregory opened this issue Sep 23, 2015 · 1 comment

Comments

@richardgregory
Copy link

Hi,

I noticed the catch statement in the transformResponse method is empty (see line below).
https://github.com/mzabriskie/axios/blob/master/lib/defaults.js#L44

If JSON.parse fails for any reason, it would be good to throw an error which would presumably be caught by the promise catch statement? Or has it been omitted for a reason?

@mzabriskie
Copy link
Member

@richardgregory yes, it was done deliberately. Current implementation is a bit dumb. If response is a string, it tries to parse the response as JSON. If it fails, it is assumed that the response must not have been JSON, fails gracefully, and passes the string response along.

See #61 for a bit more color.

@axios axios locked and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants