Registry / devops / super-fetch-proxy

super-fetch-proxy

JSON →
library1.0.2jsnpmunverified

A TypeScript-ready fetch utility that attempts a direct HTTP request first and, on failure, automatically retries via a randomly selected proxy from a user-supplied pool. Version 1.0.2 is the current stable release. It differentiates by offering zero-config proxy fallback, a simple Promise-based API, and built-in TypeScript definitions. The constructor accepts a custom proxy-fetching function, enabling dynamic proxy lists.

npm install super-fetch-proxy
INSTALL
IMPORT
SIG · SUPER-FETCH-PROXY
S
super-fetch-proxy
devopsjavascriptv1.0.2
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.

FetchWithProxyFallback
import FetchWithProxyFallback from 'super-fetch-proxy'
const FetchWithProxyFallback = require('super-fetch-proxy')
Default export only; named exports are not available. CommonJS require may work but ESM is preferred for TypeScript users.
FetchWithProxyFallback type
import type { FetchWithProxyFallback } from 'super-fetch-proxy'
import { FetchWithProxyFallback } from 'super-fetch-proxy'
TypeScript only. Use type-only import to avoid runtime overhead; the class is the default export, not a named export.
instance.fetch method
fetcher.fetch(url, options)
FetchWithProxyFallback.fetch(url, options)
fetch is an instance method, not static. You must call new FetchWithProxyFallback() first.

Shows instantiation with a proxy fetcher function and a fetch call with custom options.

import FetchWithProxyFallback from 'super-fetch-proxy'; async function getProxies() { return ['http://proxy1.example.com:8080', 'http://proxy2.example.com:8080']; } const fetcher = new FetchWithProxyFallback(getProxies); async function main() { try { const response = await fetcher.fetch('https://api.example.com/data', { method: 'GET', headers: { 'Accept': 'application/json' } }); const data = await response.json(); console.log(data); } catch (err) { console.error('Fetch failed:', err); } } main();
Debug
Known issues
gotchaThe proxyFetcher function must return an array of strings; otherwise, random selection will fail.
fix
Ensure proxyFetcher returns a Promise<string[]>.
affects: >=1.0.0
gotchaThe fetch method signature does not include the RequestInit type correctly; it expects a second argument of type any.
fix
Cast options as any if TypeScript complains: fetcher.fetch(url, options as any).
affects: 1.0.0 - 1.0.2
gotchaThe fetcher's fetch method is not bound to the instance; using it as a standalone function will lose the this context.
fix
Bind the method: const FetchUtil = fetcher.fetch.bind(fetcher);
affects: >=1.0.0
breakingIn version 1.0.0, the constructor accepted a second argument (time), but this changed to a rest parameter in 1.0.1.
fix
Pass extra arguments via rest parameters: new FetchWithProxyFallback(getProxies, ...args);
affects: 1.0.0
Errors
Common errors & fixes
TypeError: proxyFetcher is not a function
The first argument passed to new FetchWithProxyFallback() is not a function.
fix
Ensure the argument is a function that returns a Promise<string[]>.
TypeError: Cannot read properties of undefined (reading 'length')
The proxyFetcher resolved to undefined or null, or returned non-array.
fix
Make sure proxyFetcher returns a valid array of proxy strings.
Error: Fetch failed after using proxy (aggregate error)
Both direct fetch and proxy attempts failed.
fix
Check network connectivity, proxy availability, and URL correctness.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Amazon
1
Resources
super-fetch-proxy — npm install super-fetch-proxy · libregistry