fetch-plugin extends whatwg-fetch to add timeout support, JSONP requests, and global configuration similar to jQuery's ajaxSetup. Version 1.2.8, last updated in 2018. It provides methods like getJSON, postJSON, putJSON, deleteJSON, and getJSONP. Release cadence is sparse. Key differentiators: built-in timeout and JSONP support, global option merging. Suitable for legacy browsers or projects needing a simple fetch wrapper with these features. Note: the package is unmaintained and uses outdated dependencies.
npm install fetch-pluginNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates setting global options via fetch.globalOption and using getJSON, postJSON, and getJSONP methods with promise-based API.
Consider switching to native fetch (if supported) or a maintained polyfill/helper like ky or unfetch.
Do not expect .json() or .text() methods; the promise resolves directly with the response body.
Set mode to 'cors' in options to allow cross-origin requests.
Be aware that global options are merged with per-request options; use per-request options to override.
Use native fetch or a more modern polyfill.
Use import fetch from 'fetch-plugin' or const fetch = require('fetch-plugin'); do not destructure.Use const fetch = require('fetch-plugin'); then fetch.getJSON(...).