Socket
Socket
Sign inDemoInstall

fetch-jsonp-polyfill

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fetch-jsonp-polyfill

a jsonp fetch polyfill


Version published
Weekly downloads
15
Maintainers
1
Install size
13.2 kB
Created
Weekly downloads
 

Readme

Source

fetch-jsonp-polyfill

JSONP is NOT supported in standard Fetch API.If you are sleepy for such a problem, please use this Polyfill.

Installation

You can install with npm.

npm install fetch-jsonp-polyfill --save-dev

Notice

He can be compatible with almost all current jsonp polyfills, includinghttps://github.com/github/fetch https://github.com/matthew-andrews/isomorphic-fetch https://github.com/bitinn/node-fetch and many more.

Please note that they must be imported after them.

require('isomorphic-fetch');
require('fetch-jsonp-polyfill');

Usage

You don't need to make any changes, just modify the method:'GET' to method:'JSONP'. In this way, I didn't modify any native code.

var URL = 'http://jsfiddle.net/echo/jsonp/';

fetch(URL, {
    method: "JSONP"
})
.then(res => res.json())
.then(data => {
    console.log(data);
})
.catch(err => {
    console.log(err);
});

Other Options

fetch(URL, {
    method: 'JSONP',
    timeout: 5000,
    callback: 'callback',
    callbackName: 'fetchjsonp_callback',
})

Browser Support

ChromeFirefoxIEOperaSafari
Latest ✔Latest ✔9+ ✔Latest ✔6.1+ ✔

License

MIT

Keywords

FAQs

Last updated on 03 Apr 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc