| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Switches between unfetch & node-fetch for client & server.
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-unfetchThen 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");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);
});| Back | FazBrowse Home | New Git URL |