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

Feature request: Adding XMLHttpRequest support to the Node.js version #2736

Closed
chumo opened this issue Feb 14, 2016 · 2 comments
Closed

Feature request: Adding XMLHttpRequest support to the Node.js version #2736

chumo opened this issue Feb 14, 2016 · 2 comments

Comments

@chumo
Copy link

chumo commented Feb 14, 2016

I noticed that d3.xhr and its convenient methods (like d3.json) do not work in Node.js due to a lack of an implemented XMLHttpRequest there. Wouldn't it be easy enough to add a dependency to the xmlhttprequest npm package? This way the Node version would work as well as the browser version by adding:

var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;

@mbostock
Copy link
Member

I’ve opened d3/d3-request#8 as a request for the d3-request module in 4.0. I’m all for this, although I don’t yet know how to express this optional dependency in conjunction with Rollup so that the require only happens in a Node environment (and not, for example, in Browserify consuming the CommonJS / UMD bundle). One possibility is a wrapper script as the main entry in the package.json, and then a separate Browserify entry, but then the wrapper has to expose the XMLHttpRequest symbol globally… so, blech.

@mbostock
Copy link
Member

d3-request now supports Node in 0.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants