You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Instead of defaulting to
json
for body parsing, it would be better if we read the response'sContent-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 needblob
orarrayBuffer
.The text was updated successfully, but these errors were encountered: