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
Return empty object on 204 No Content... #165
Comments
While I like the idea of an empty object as a JSON response, this moves away from the spec, as they've consciously stayed with throwing an error - IMO it'd be better to stay with the spec for compatibility with native fetch implementations, but if not, should this at least be added as a known difference? |
I agree. Plus, there's also the question whether we should return an empty object, or an empty string, or |
For me, the best thing is to stick with spec - an example use case I'm dealing with is running tests in JSDOM, but now the interface is different between a native client e.g. Chrome and the server side usage. The same applies to |
I am asking browser vendors for opinions in the same WHATWG thread. But status quo seems clear at this point, neither native implementation/browser fetch polyfill/spec handle 204 empty response. We should revert our code to match their behaviour in |
Agreed. I'll prepare a PR. |
Thanks very much for the quick response - really appreciate your efforts on this, it's a great polyfill. Cheers! |
Fixed in #201. |
...instead of throwing a syntax error due to attempting to JSON parse
''
.Demo: http://runkit.com/dandv/node-fetch-204-no-content
Fixing this would attain compatibility with request and got.
More generally, it would be more tolerant to return an empty object if the response is the empty string (regardless of the status code being 204 or other 2xx).
The text was updated successfully, but these errors were encountered: