-
Notifications
You must be signed in to change notification settings - Fork 178
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
Replaced request
with node-fetch
#195
Conversation
I believe |
theResponse = response | ||
return response.text() | ||
}).then(function (body) { | ||
body = body === '' ? {} : JSON.parse(body) // workaround for https://github.com/bitinn/node-fetch/issues/165 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps checking the statusCode for 204s would be cleaner here? I believe the issue on node-fetch
would break away from the whatwg specification, which simply states that response.json()
should
[r]eturn the result of invoking the initial value of the parse property of the JSON object with the result of running utf-8 decode on bytes as argument. Rethrow any exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be less resilient to imperfect implementations that return, say, 200 and an empty response, but it would help catch that error.
I've amended my PR to node-fetch to check for a status code of 204 instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's less resilient, but as far as adding it in node-fetch:
- it is a breaking API change
- empty objects are not necessarily equivalent to empty responses
- it breaks away from the specification which node-fetch is trying to match (!)
- it also will not be a feature in browsers; even if github/fetch also accepts such a change, it won't be present in browsers on which the polyfill is not applied (modern Chrome/FireFox)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't GitHub be hiding this discussion now that it refers to an outdated diff?
After some review for integration with 5.x, I'm not totally sure that using
It seems like using the |
Influent works in the browser by using a small HTTP module, hurl, which uses XHR. |
request
with node-fetch
FWIW, this branch works without problems in the browser, without isomorphic-fetch. I've tested with jspm 0.17, connecting over HTTPS to the InfluxDB server. |
Can you rebase on or back-merge in master? Happy to add this in now, though I still want to stick with with native |
@connor4312: closing in favor of the #202 rebase. |
node-tech
for use with isomorphic-fetch in browsers, instead ofgot
.