isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify

MIT 23 个版本
安装
npm install isomorphic-fetch
yarn add isomorphic-fetch
pnpm add isomorphic-fetch
bun add isomorphic-fetch
README

isomorphic-fetch Build Status

Fetch for node and Browserify. Built on top of GitHub's WHATWG Fetch polyfill.

Warnings

  • This adds fetch as a global so that its API is consistent between client and server.

For ease-of-maintenance and backward-compatibility reasons, this library will always be a polyfill. As a "safe" alternative, which does not modify the global, consider fetch-ponyfill.

Why Use Isomorphic Fetch

The Fetch API is currently not implemented consistently across browsers. This module will enable you to use fetch in your Node code in a cross-browser compliant fashion. The Fetch API is part of the Web platform API defined by the standards bodies WHATWG and W3C.

Installation

NPM

npm install --save isomorphic-fetch

Bower

bower install --save isomorphic-fetch

Usage

require('isomorphic-fetch');

fetch('//offline-news-api.herokuapp.com/stories')
	.then(function(response) {
		if (response.status >= 400) {
			throw new Error("Bad response from server");
		}
		return response.json();
	})
	.then(function(stories) {
		console.log(stories);
	});

License

All open source code released by FT Labs is licenced under the MIT licence. Based on the fine work by jxck.

Alternatives

版本列表
3.0.0 2020-09-23
2.2.1 2016-01-15
2.2.0 2015-10-20
2.1.1 2015-07-16
2.1.0 2015-05-21
2.0.2 2015-04-15
2.0.1 2015-04-06
2.0.0 2015-02-10
1.7.0 2015-01-27
1.6.1 2015-01-26
1.6.0 2015-01-24
1.5.2 2015-01-23
1.5.1 2015-01-23
1.5.0 2015-01-23
1.4.0 2015-01-21
1.3.0 2015-01-19
1.2.0 2015-01-15
1.1.3 2015-01-13
1.1.2 2015-01-12
1.1.1 2015-01-12
1.1.0 2014-12-29
1.0.2 2014-12-29
1.0.0 2014-11-07