78853fc544 | ||
---|---|---|
test | ||
.gitignore | ||
CHANGELOG.md | ||
LICENSE.md | ||
LIMITS.md | ||
README.md | ||
index.js | ||
package.json |
README.md
node-fetch
A light-weight module that brings window.fetch to node.js
Motivation
I like the notion of Matt Andrews' isomorphic-fetch: it bridges the API gap between client-side and server-side http requests, so developers have less to worry about.
But I believe the term isomorphic is generally misleading: it gives developers a false sense of security that their javascript code will run happily on both controlled server environment as well as uncontrollable user browsers. When the latter is only true for a small subset of modern browsers, not to mention quirks in native implementation.
Instead of implementing XMLHttpRequest
in node to run browser-specific fetch polyfill, why not go from node's http
to fetch
API directly? Node has native stream support, your browserify build targets (browsers) don't, so underneath they are going to be vastly different anyway.
IMHO, it's safer to be aware of javascript runtime's strength and weakness, than to assume they are a unified platform under a stable spec.
Hence node-fetch
.
Features
- Stay consistent with
window.fetch
API. - Make conscious trade-off when following whatwg fetch spec and stream spec implementation details, document known difference.
- Use native promise, but allow substituting it with [insert your favorite promise library].
Limits
- Work in progress, much like the spec itself.
- See LIMITS.md
(If you spot a undocumented difference, feel free to open an issue. Pull requests are welcomed too!)
Install
npm install node-fetch --save
Usage
TODO
License
MIT
Acknowledgement
Thanks to github/fetch for providing a solid implementation reference.