Node-fetch: document isomorphic usage

Created on 18 May 2016  路  3Comments  路  Source: node-fetch/node-fetch

The README should document how to use node-fetch in a polyfill fashion, perhaps with a Webpack exemple that shows how to load whatwg-fetch or node-fetch conditionally. This is not something obvious as node-fetch might actually need to be patched to act in a polyfill fashion vs. a simple ProvidePlugin, which would fail with external node_modules not processed by Webpack for example.

This will work properly with isomorphic-fetch because it polyfills, but I have not yet found a proper way to do it with Webpack.

node-fetch might possibly need to be updated to provide something like import 'node-fetch/polyfill so that it can be used in a truly isomorphic fashion.

Most helpful comment

Yes, that make sense. The isomorphic question aside, node-fetch should probably provide a polyfill functionality, so it can be used with libraries that depend on fetch being available as a global.

All 3 comments

node-fetch is not trying to be isomorphic, while isomorphic-fetch is, it would be much better to provide such info on isomorphic-fetch readme.

Yes, that make sense. The isomorphic question aside, node-fetch should probably provide a polyfill functionality, so it can be used with libraries that depend on fetch being available as a global.

I am closing this as decision is still to leave polyfilling to isomorphic-fetch (or you can write your simple module to expose node-fetch to global)

Was this page helpful?
0 / 5 - 0 ratings