Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fetch-ponyfill

qubyte716kMIT7.1.0TypeScript support: included

A ponyfill (doesn't overwrite the native fetch) for the Fetch specification https://fetch.spec.whatwg.org.

fetch, ponyfill

readme

Fetch Ponyfill

WHATWG fetch ponyfill

This module wraps the github/fetch polyfill in a CommonJS module for browserification, and avoids appending anything to the window, instead returning a setup function when fetch-ponyfill is required. Inspired by object-assign.

When used in Node, delegates to node-fetch instead.

Usage

Browserify

const {fetch, Request, Response, Headers} = require('fetch-ponyfill')(options);

Webpack

import fetchPonyfill from 'fetch-ponyfill';
const {fetch, Request, Response, Headers} = fetchPonyfill(options);

Options

Where options is an object with the following optional properties:

option description
Promise An A+ Promise implementation. Defaults to window.Promise in the browser, and global.Promise in Node.
XMLHttpRequest The XMLHttpRequest constructor. This is useful to feed in when working with Firefox OS. Defaults to window.XMLHttpRequest. Has no effect in Node.

changelog

History

7.1.0

  • Updates whatwg-fetch to 3.5.0 to address an issue with IE11.

7.0.0

  • Drops support for node 8. Adds node 14 to tests.
  • Updates whatwg-fetch to ~3.4.1.
  • Exposes DOMException from whatwg-fetch.
  • Tests against webpack 5 and browserify 17.

6.1.0

  • Adds a types field to package.json for TypeScript integration.
  • Updates node-fetch to 2.6.0

6.0.2

  • Fixes WHATWG URL object handling when this module is used in Node.

6.0.1

  • Fixes to the TypeScript declaration file.

6.0.0

  • Adjusts the way the global object is sniffed for use with Metro.

5.0.0

  • Bumps node-fetch from ~1.7.1 to ~2.0.0. This is a potentially breaking change. Refer to the node-fetch upgrade guide for details.

4.1.0

  • Bumps node fetch from ~1.6.0 to ~1.7.1.
  • Bumps whatwg-fetch from ~2.0.1 to ~2.0.3.

4.0.0

This release:

  • Bumps whatwg-fetch from ~1.0.0 to ~2.0.1.
  • Better handling of self/this for browser fetch (more testing friendly).

3.0.2

Dependencies now use tilde to allow patch versions to be tracked (this was waiting for whatwg-fetch to reach version 1).

3.0.1

A link was added to the README to point to the ponyfill definition.

3.0.0

Fixes an issue with detection of features like URLSearchParams. This is a major version bump since apparent behaviour could change in a breaking way in browsers which support detected features.

2.0.0

Now exposes associated constructors along with fetch like:

const {fetch, Request, Response, Headers} = require('fetch-ponyfill')(options);