https://github.com/qubyte/fetch-ponyfill
WHATWG fetch ponyfill
https://github.com/qubyte/fetch-ponyfill
fetch fetch-api javascript ponyfill whatwg
Last synced: 5 months ago
JSON representation
WHATWG fetch ponyfill
- Host: GitHub
- URL: https://github.com/qubyte/fetch-ponyfill
- Owner: qubyte
- License: mit
- Created: 2014-12-27T15:38:54.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2022-01-25T11:21:11.000Z (over 3 years ago)
- Last Synced: 2025-05-03T02:07:37.041Z (5 months ago)
- Topics: fetch, fetch-api, javascript, ponyfill, whatwg
- Language: JavaScript
- Homepage:
- Size: 782 KB
- Stars: 235
- Watchers: 6
- Forks: 38
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome - qubyte/fetch-ponyfill - WHATWG fetch ponyfill (JavaScript)
README
# Fetch Ponyfill
> WHATWG `fetch` [ponyfill](https://ponyfill.com)
This module wraps the [github/fetch](https://github.com/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](https://github.com/sindresorhus/object-assign).When used in Node, delegates to `node-fetch` instead.
## Usage
### Browserify
```javascript
const {fetch, Request, Response, Headers} = require('fetch-ponyfill')(options);
```### Webpack
```javascript
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. |