isomorphic-unfetch
Switches between unfetch & node-fetch for client & server.
Last updated 3 years ago by developit .
MIT · Repository · Bugs · Original npm
$ 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.

Note: This module uses node-fetch 3.x, which is ES Module and requires Node >= 12.20.0.

$ npm i 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
const 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

  • 4.0.2                                ...           latest (3 years ago)

4 Versions

  • 4.0.2                                ...           3 years ago
  • 3.1.0                                ...           5 years ago
  • 3.0.0                                ...           7 years ago
  • 2.1.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org