isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify

  • Owner: matthew-andrews/isomorphic-fetch
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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.
  • You must bring your own ES6 Promise compatible polyfill, I suggest es6-promise.

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.

Installation

NPM

npm install --save isomorphic-fetch es6-promise

Bower

bower install --save isomorphic-fetch es6-promise

Usage

require('es6-promise').polyfill();
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.

Main metrics

Overview
Name With Ownermatthew-andrews/isomorphic-fetch
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2014-11-07 08:46:13
Pushed At2024-06-27 10:34:24
Last Commit At2020-09-23 16:24:11
Release Count26
Last Release Namev3.0.0 (Posted on 2020-09-23 16:24:11)
First Release Namev1.0.0 (Posted on 2014-11-07 21:18:06)
用户参与
Stargazers Count6.9k
Watchers Count79
Fork Count286
Commits Count91
Has Issues Enabled
Issues Count152
Issue Open Count45
Pull Requests Count19
Pull Requests Open Count11
Pull Requests Close Count28
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private