{"id":49754,"library":"wonderful-fetch","title":"wonderful-fetch","description":"A powerful wrapper around the native fetch API that works in both Node.js (>=18) and browser environments. Current stable version is 2.0.5, released actively by ITW Creative Works. Key differentiators include automatic JSON response parsing, retries with exponential backoff, request timeouts via AbortController, authorization header management (auto-prefixes 'Bearer '), query parameter building, cache busting, file downloads (Node.js only), and enriched error objects with HTTP status codes. Designed to simplify common fetch patterns while retaining full flexibility.","status":"active","version":"2.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/itw-creative-works/wonderful-fetch","tags":["javascript","rest api"],"install":[{"cmd":"npm install wonderful-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add wonderful-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add wonderful-fetch","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a single default export, not a named export.","wrong":"import { fetch } from 'wonderful-fetch'","symbol":"default (fetch)","correct":"import fetch from 'wonderful-fetch'"},{"note":"CommonJS users must require the default export.","wrong":"const { fetch } = require('wonderful-fetch')","symbol":"CommonJS require","correct":"const fetch = require('wonderful-fetch')"},{"note":"CDN exposes WonderfulFetch as a global function, not fetch.","wrong":"fetch('https://api.example.com/data') // undefined in global scope","symbol":"CDN global","correct":"<script src=\"https://cdn.jsdelivr.net/npm/wonderful-fetch@latest/dist/wonderful-fetch.min.js\"></script>\nWonderfulFetch('https://api.example.com/data', { response: 'json' })"}],"quickstart":{"code":"import fetch from 'wonderful-fetch';\n\nasync function main() {\n  try {\n    const data = await fetch('https://httpbin.org/json', {\n      method: 'get',\n      response: 'json',\n      tries: 3,\n      timeout: 10000,\n      authorization: process.env.API_KEY ?? '',\n    });\n    console.log('Data:', data);\n  } catch (err) {\n    console.error('Error:', err.message, 'Status:', err.status);\n  }\n}\n\nmain();","lang":"javascript","description":"Shows a basic GET request with JSON response, retries, timeout, and authorization header."},"warnings":[{"fix":"Upgrade Node.js to >=18 or use wonderful-fetch@1.x.","message":"Version 2.x dropped support for Node.js <18.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Access status, headers, and body individually or use a newer API pattern.","message":"The 'output' option with value 'complete' is deprecated. Use separate properties or a dedicated response type.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Pass authorization as 'Basic abc123' to avoid unwanted 'Bearer ' prefix.","message":"Authorization auto-prefixes 'Bearer ' if no scheme is provided. If you want a custom scheme (e.g., 'Basic'), include it explicitly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For FormData or other body types, do not wrap in an object that triggers JSON serialization.","message":"Request body objects are automatically JSON-stringified. To send a non-JSON body (e.g., FormData), pass it as-is.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Guard file downloads with environment detection: if (typeof window === 'undefined') { /* download */ }","message":"The 'download' option only works in Node.js. Using it in a browser will throw an error.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'18':17 '2.0.5':25 'abortcontrol':46 'activ':27 'api':11,83 'around':7 'author':47 'auto':51 'auto-prefix':50 'automat':35 'backoff':42 'bearer':53 'browser':19 'build':56 'bust':58 'cach':57 'code':70 'common':74 'creativ':30 'current':21 'design':71 'differenti':33 'download':60 'enrich':64 'environ':20 'error':65 'exponenti':41 'fetch':3,10,75 'file':59 'flexibl':80 'full':79 'header':48 'http':68 'includ':34 'itw':29 'javascript':81 'json':36 'key':32 'manag':49 'nativ':9 'node.js':16,61 'object':66 'paramet':55 'pars':38 'pattern':76 'power':5 'prefix':52 'queri':54 'releas':26 'request':43 'respons':37 'rest':82 'retain':78 'retri':39 'simplifi':73 'stabl':22 'status':69 'timeout':44 'version':23 'via':45 'wonder':2 'wonderful-fetch':1 'work':13,31 'wrapper':6","created_at":"2026-06-07T17:03:26.325115+00:00","updated_at":"2026-06-07T17:03:26.325115+00:00","problems":[{"fix":"Use import fetch from 'wonderful-fetch' (default import).","cause":"Using a named import instead of default import (import { fetch } from 'wonderful-fetch').","error":"Uncaught ReferenceError: fetch is not defined"},{"fix":"Pass a valid URL string as the first argument.","cause":"Calling fetch() without a URL argument.","error":"TypeError: Failed to parse URL from undefined"},{"fix":"Check the URL or handle the error with try/catch and inspect err.status.","cause":"Server returned a non-2xx response. The error includes the response body.","error":"Error: Request failed with status 404"},{"fix":"Only use 'download' in Node.js, or wrap with environment check.","cause":"Using the 'download' option in a browser environment.","error":"Error: download is not supported in the browser"}],"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://itwcreativeworks.com","github":"https://github.com/itw-creative-works/wonderful-fetch","docs":null,"changelog":null,"pypi":null,"npm":"wonderful-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}