Go to file
David Frank 5cb7365d5c release 0.1.0 2015-01-27 21:13:28 +08:00
lib basic refactor done 2015-01-27 21:11:26 +08:00
test basic refactor done 2015-01-27 21:11:26 +08:00
.gitignore setup repo 2015-01-26 17:02:34 +08:00
CHANGELOG.md release 0.1.0 2015-01-27 21:13:28 +08:00
LICENSE.md setup repo 2015-01-26 17:02:34 +08:00
LIMITS.md release 0.1.0 2015-01-27 21:13:28 +08:00
README.md basic refactor done 2015-01-27 21:11:26 +08:00
index.js basic refactor done 2015-01-27 21:11:26 +08:00
package.json basic refactor done 2015-01-27 21:11:26 +08:00

README.md

node-fetch

npm version build status

A light-weight module that brings window.fetch to node.js

Motivation

I really 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 think 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 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, browserify build targets (browsers) don't, so underneath they are going to be vastly different anyway.

Hence node-fetch, minimal code for a window.fetch compatible API on node.js runtime.

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].

Difference from client-side fetch

  • See Known limits for details.
  • If you happen to use a missing feature that window.fetch offers, 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.