Registry / devops / wise-fetch

wise-fetch

JSON →
library0.4.0-1jsnpmunverified

A feature-rich wrapper around node-fetch that adds built-in RFC 7234 compliant response caching, proxy support, abortable requests (AbortController), base URL resolution, automatic rejection of non-2xx/304 responses, and strict URL validation. Version 0.4.0-1 (pre-release). Based on make-fetch-happen and node-fetch-npm. Low release cadence (last release ~2019). Differentiates from plain node-fetch by bundling caching (to OS temp dir), proxy (reads npm config), and base URL support out of the box.

npm install wise-fetch
INSTALL
IMPORT
SIG · WISE-FETCH
W
wise-fetch
devopsjavascriptv0.4.0-1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wiseFetch
✓ import wiseFetch from 'wise-fetch'
✗ const { wiseFetch } = require('wise-fetch')
Package uses CommonJS module.exports; default import via require is correct. Named import will fail.
wiseFetch (default)
✓ const wiseFetch = require('wise-fetch')
✗ import { wiseFetch } from 'wise-fetch'
ESM default import works if using bundler/interop, but CommonJS require is the documented pattern.
options
✓ wiseFetch('url', { baseUrl: '...', proxy: '...' })
Options are passed as second argument; all make-fetch-happen options are supported except counter and cacheManager.

Fetches a JSON API, demonstrates error handling for non-2xx responses, and parses JSON body.

const wiseFetch = require('wise-fetch'); (async () => { try { const response = await wiseFetch('https://api.github.com/repos/shinnn/wise-fetch', { headers: { 'User-Agent': 'wise-fetch-demo' } }); const data = await response.json(); console.log(data.full_name); } catch (err) { console.error('Request failed:', err.message); if (err.response) { console.error('Status:', err.response.status); } } })();
Debug
Known issues
gotchaAutomatic rejection on non-2xx/304 responses: unlike browser fetch, wiseFetch rejects the promise for 4xx/5xx responses. Catch errors and access err.response to get the response object.
fix
Wrap fetch in try/catch and check err.response.status instead of relying on response.ok.
affects: >=0.0.0
deprecatedPackage uses node-fetch-npm (deprecated) which is a fork of node-fetch v2. It may not receive security updates.
fix
Consider migrating to native fetch (Node 18+) or node-fetch v3 with manual caching/proxy implementation.
affects: >=0.0.0
gotchaCaching uses OS temp directory (os.tmpdir()) which may not be persisted across reboots. Cache behavior is RFC 7234 compliant but may cause stale data in long-running processes.
fix
Clear cache manually by deleting temp files if needed. Not configurable.
affects: >=0.0.0
gotchaproxy and noProxy options default to npm config values when running as npm script. May produce unexpected proxy behavior outside npm context.
fix
Explicitly set proxy: null to disable proxy, or set proxy option explicitly.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: fetch is not a function
Attempting to import wiseFetch as a named export (ESM named import) or using it without importing.
fix
Use default import: const wiseFetch = require('wise-fetch');
UnhandledPromiseRejectionWarning: Error: 404 (Not Found) responded by a GET request to ...
wiseFetch rejects on HTTP error status by default; not catching the rejection.
fix
Add .catch() or try/catch around the fetch call.
Error: getaddrinfo ENOTFOUND ...
Invalid/misspelled URL or network unreachable; wiseFetch performs strict URL validation.
fix
Ensure URL is absolute and correctly formatted. Use baseUrl option for relative URLs.
Upgrade
Version history
0.4.0-1latest on npm
Audit
Dependencies
make-fetch-happenrequiredCore HTTP client with caching and proxy support.
node-fetch-npmrequiredResponse class polyfill used for compatibility.
Agent activity
14 hits · last 30 days
node
12
Resources
wise-fetch — npm install wise-fetch · libregistry