Registry / testing / feature-fetch

feature-fetch

JSON →
library0.1.0jsnpmunverified

Typed fetch client for JavaScript/TypeScript (v0.1.0) that returns tuple results [data, error] for safer error handling. Supports opt-in features like REST, OpenAPI, GraphQL, retry, and request caching. It differentiates from raw fetch and other clients (ky, axios) by providing type-safe responses out of the box and composable modular features. Currently in early development with rapid iteration.

npm install feature-fetch
INSTALL
IMPORT
SIG · FEATURE-FETCH
F
feature-fetch
testingjavascriptv0.1.0
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.

featureFetch
✓ import { featureFetch } from 'feature-fetch'
✗ const featureFetch = require('feature-fetch')
ESM-only; requires Node >= 12 or bundler that supports ESM.
createClient
✓ import { createClient } from 'feature-fetch'
✗ import { createClient } from 'feature-fetch/client'
createClient is exported from main entry since v0.1.0.
FetchError
✓ import { FetchError } from 'feature-fetch'
Type is automatically inferred from tuple result; rarely needed explicitly.
type ClientConfig
✓ import type { ClientConfig } from 'feature-fetch'
✗ import { ClientConfig } from 'feature-fetch'
ClientConfig is a type-only export; use import type to avoid runtime issues.

Shows basic usage of featureFetch.get with tuple result for error-first handling.

import { featureFetch } from 'feature-fetch'; async function getUser(id: string) { const [error, user] = await featureFetch.get(`https://api.example.com/users/${id}`); if (error) { console.error('Failed to fetch user:', error); return; } console.log('User:', user); } getUser('123');
Debug
Known issues
gotchaTuple result order is [error, data] — not [data, error] like Go.
fix
Always destructure as [error, data].
affects: >=0.0.1
deprecatedOptions passed as second argument to each method (get, post, etc.) will be removed in v1.0 in favor of client-level config.
fix
Use createClient with base config instead of per-call options.
affects: >=0.1.0
breakingIn v0.2.0, the return type for non-JSON responses changed from text to a Blob.
fix
Handle Blob responses explicitly or use .text() method if needed.
affects: >=0.2.0
Errors
Common errors & fixes
Cannot find module 'feature-fetch' or its corresponding type declarations.
Missing tsconfig.json configuration for ESM modules.
fix
Set "module": "ESNext" and "moduleResolution": "node" or "bundler" in tsconfig.json.
TypeError: (0 , feature_fetch_1.featureFetch) is not a function
Using CommonJS require() instead of ESM import.
fix
Use import { featureFetch } from 'feature-fetch' and ensure project uses ESM.
Uncaught TypeError: Failed to execute 'json' on 'Response': body stream already read
Reading response body twice when using retry feature.
fix
Use clone() on response before retrying or set cache: 'no-store' in request options.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
feature-fetch — npm install feature-fetch · libregistry