isomorphic-unfetch
Switches between unfetch & node-fetch for client & server.
Last updated 2 years ago by developit .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install isomorphic-unfetch 
SYNC missed versions from official npm registry.

Isomorphic Unfetch

Switches between unfetch & node-fetch for client & server.

Install

This project uses node and npm. Go check them out if you don't have them locally installed.

$ npm install --save isomorphic-unfetch

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import fetch from 'isomorphic-unfetch'

// using CommonJS modules
var fetch = require('isomorphic-unfetch')

Usage

As a ponyfill:

import fetch from 'isomorphic-unfetch';

fetch('/foo.json')
  .then( r => r.json() )
  .then( data => {
    console.log(data);
  });

Globally, as a polyfill:

import 'isomorphic-unfetch';

// "fetch" is now installed globally if it wasn't already available

fetch('/foo.json')
  .then( r => r.json() )
  .then( data => {
    console.log(data);
  });

License

MIT License © Jason Miller

Current Tags

  • 3.0.0                                ...           latest (2 years ago)

6 Versions

  • 3.0.0                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 23
This Week 1,045
This Month 1,141
Last Day 37
Last Week 1,441
Last Month 5,868
Dependencies (2)
Dev Dependencies (0)
None
Dependents (577)

Copyright 2014 - 2017 © taobao.org |