{"id":47633,"library":"fetch-plugin","title":"fetch-plugin","description":"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.","status":"deprecated","version":"1.2.8","language":"javascript","source_language":"en","source_url":"https://github.com/jfw10973/fetch-plugin","tags":["javascript","fetch","timeout"],"install":[{"cmd":"npm install fetch-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add fetch-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add fetch-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"fetch-plugin extends whatwg-fetch polyfill to provide fetch functionality; it is a direct dependency","package":"whatwg-fetch","optional":false}],"imports":[{"note":"Default export is the fetch object with added methods (getJSON, postJSON, etc.). CommonJS require works but destructuring may not work as expected because the default export is a function with properties.","wrong":"const { fetch } = require('fetch-plugin')","symbol":"fetch","correct":"import fetch from 'fetch-plugin'"},{"note":"In CommonJS, require returns the default export directly, so .default is incorrect.","wrong":"const fetch = require('fetch-plugin').default","symbol":"fetch","correct":"const fetch = require('fetch-plugin')"},{"note":"The method signature expects optional data as second argument and optional options as third.","wrong":"fetch.getJSON(url, options, data)","symbol":"fetch.getJSON","correct":"fetch.getJSON(url, data, options)"}],"quickstart":{"code":"import fetch from 'fetch-plugin';\n\n// Set global options\nfetch.globalOption = {\n  timeout: 5000,\n  fetchStart: () => console.log('Request started'),\n  fetchSuccess: (response) => console.log('Success', response),\n  fetchError: (error) => console.log('Error', error.message),\n};\n\n// GET request\nfetch.getJSON('https://api.example.com/data', { key: 'value' })\n  .then(result => console.log(result))\n  .catch(error => console.error(error));\n\n// POST request\nfetch.postJSON('https://api.example.com/data', { name: 'test' })\n  .then(result => console.log(result));\n\n// JSONP request (callback name can be set in options)\nfetch.getJSONP('https://api.example.com/jsonp', { q: 'test' })\n  .then(result => console.log(result));","lang":"javascript","description":"Demonstrates setting global options via fetch.globalOption and using getJSON, postJSON, and getJSONP methods with promise-based API."},"warnings":[{"fix":"Consider switching to native fetch (if supported) or a maintained polyfill/helper like ky or unfetch.","message":"Package is unmaintained since 2018; last version 1.2.8 uses whatwg-fetch 2.x which is outdated.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Do not expect .json() or .text() methods; the promise resolves directly with the response body.","message":"JSONP method getJSONP does not return a standard Fetch Response; it resolves with the parsed JSON data from the callback.","severity":"broken","affected_versions":">=1.0.0"},{"fix":"Set mode to 'cors' in options to allow cross-origin requests.","message":"The default mode is 'same-origin' which may block cross-origin requests unless CORS is configured.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Be aware that global options are merged with per-request options; use per-request options to override.","message":"Global options are mutated; setting fetch.globalOption.timeout = 5000 will affect all subsequent requests.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use native fetch or a more modern polyfill.","message":"The package depends on whatwg-fetch which has known CORS issues in older browsers; no updates.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.2.8':26 '2018':30 'add':12 'ajaxsetup':24 'browser':60 'built':48 'built-in':47 'cadenc':42 'configur':19 'deletejson':38 'depend':79 'differenti':46 'extend':7 'featur':70 'fetch':2,5,10,66,81 'fetch-plugin':1,4 'getjson':35 'getjsonp':40 'global':18,54 'javascript':80 'jqueri':22 'jsonp':15,52 'key':45 'last':27 'legaci':59 'like':34 'merg':56 'method':33 'need':63 'note':71 'option':55 'outdat':78 'packag':73 'plugin':3,6 'postjson':36 'project':62 'provid':32 'putjson':37 'releas':41 'request':16 'similar':20 'simpl':65 'spars':44 'suitabl':57 'support':14,53 'timeout':13,50,82 'unmaintain':75 'updat':28 'use':77 'version':25 'whatwg':9 'whatwg-fetch':8 'wrapper':67","created_at":"2026-06-07T16:52:30.727884+00:00","updated_at":"2026-06-07T16:52:30.727884+00:00","problems":[{"fix":"Use import fetch from 'fetch-plugin' or const fetch = require('fetch-plugin'); do not destructure.","cause":"Attempting to destructure fetch from the module or using import incorrectly.","error":"fetch is not a function"},{"fix":"Use const fetch = require('fetch-plugin'); then fetch.getJSON(...).","cause":"Using CommonJS with require and expecting named exports, but the default export is the fetch function itself with getJSON attached.","error":"fetch.getJSON() is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/jfw10973/fetch-plugin#readme","github":"https://github.com/jfw10973/fetch-plugin","docs":null,"changelog":null,"pypi":null,"npm":"fetch-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}