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

Smart body parsing based on Content-Type #9

Closed
techniq opened this issue Mar 27, 2018 · 0 comments
Closed

Smart body parsing based on Content-Type #9

techniq opened this issue Mar 27, 2018 · 0 comments

Comments

@techniq
Copy link
Owner

techniq commented Mar 27, 2018

Instead of defaulting to json for body parsing, it would be better if we read the response's Content-Type header and parsed accordingly. This would also better handle when the endpoint changes types (ex. some frameworks will return a HTML debug page when a 500 is thrown, which breaks when we expect an endpoint to return JSON).

After a quick look around, it appears fetch-parse has a good start on the mapping between Content-Type and parsers.

Probably look at using one of the following to parse the header / mime type, as it can be fairly involved to cover all cases defined by the spec.

Lastly, it would be nice to support passing a function to as to allow the user to perform the body parsing mapping themselves (might be needed to determine whether they need blob or arrayBuffer.

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