-
Notifications
You must be signed in to change notification settings - Fork 23
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
Change default as
in parse middleware
#34
Comments
Hmm, I'm not sure why The purpose of that Perhaps instead we should just change the |
The analysis by @agilgur5 is right. I ran into the same problem: using Changing to It seems like it would be better to change the default value for |
I'm guessing you haven't run into this because GitHub's WHATWG Fetch polyfill doesn't have support for streaming, whereas the browsers do now: JakeChampion/fetch#198 |
- Prevents the default parse approach from returning `Response#body` (a `ReadableStream` without a `body` property) as the response - Bumped major version because this is a backwards-incompatible change for people using the default value of 'as' with parse() - Fixes mjackson#34
@rehevkor5 thanks for debugging this! I was confused as to why I was getting an error when there's a passing unit test on this -- didn't even think to check for environment differences / the underlying |
This bit me today too! |
Currently the default property for
as
isbody
, but the logic makes this undesirables, as:https://github.com/mjackson/http-client/blob/master/modules/index.js#L205
will by default return
response.body
, which may already be populated.I run a response middleware after the parse usually, but using
parse('json'), recv(({body}) => body)
results in
undefined
to be output.If I instead use
parse('json', 'jsonData'), recv(({jsonData}) => jsonData)
,it works as intended, returning the JSON/JS Object.
Not sure what a better name would be; perhaps
bodyData
sticking by previous conventions?The text was updated successfully, but these errors were encountered: