Registry / devops / fetch-ext

fetch-ext

JSON →
library2.0.0jsnpmunverified

Native fetch wrapper adding retry, timeout, and JSON shortcuts. v2.0.0 (2024), ESM-only with TypeScript declarations. Retry supports configurable methods, delays, and limits. Differentiator: light extension of the native API vs. polyfill-heavy alternatives like node-fetch or axios. Minimal overhead for Node.js >=20.14.

devops
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.

ESM-only; require() throws ERR_REQUIRE_ESM

import { fetchExt } from 'fetch-ext'

Named export fetchExt is preferred; default export also available

import fetchExt from 'fetch-ext'

Import type for request options to extend custom fetch wrappers

import type { FetchExtRequestInit } from 'fetch-ext'

Exact casing: HttpError, not HTTPError

import { HttpError } from 'fetch-ext'

Demonstrates a GET request with 5s timeout, 3 retries, JSON body, and automatic response body parsing.

import { fetchExt } from 'fetch-ext'; async function getData() { try { const response = await fetchExt('https://api.example.com/data', { extension: { timeout: 5000, retry: { limit: 3, delay: 200, methods: ['GET', 'POST'] }, json: { key: 'value' } } }); const data = await response.extension.body(); console.log(data); } catch (error) { console.error('Request failed:', error); } } getData();
Debug
Known footguns
breakingfetch-ext is ESM-only. CommonJS require() throws ERR_REQUIRE_ESM.
breakingMinimum Node.js version is 20.14. Older versions are not supported.
deprecatedThe default export (import fetchExt from 'fetch-ext') is deprecated; use named export fetchExt instead.
gotcharesponse.extension.body() infers parser from Content-Type; expecting JSON but getting HTML will throw.
gotcharetry.limit defaults to 1, meaning 1 retry (2 total attempts). Users may inadvertently over-retry.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
1
Resources