🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

fetch-extras

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-extras

Useful utilities for working with Fetch

Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
24K
93.5%
Maintainers
1
Weekly downloads
 
Created
Source

fetch-extras logo

Useful utilities for working with Fetch

Great for creating tiny custom HTTP clients without a heavy dependency. Fully tree-shakeable.

For a full-featured HTTP client on top of Fetch, check out my ky package.

Install

npm install fetch-extras

Usage

import {
	pipeline,
	withTimeout,
	withBaseUrl,
	withHeaders,
	withHttpError
} from 'fetch-extras';

// Create a tiny reusable API client that:
// - Times out after 5 seconds
// - Uses a base URL so you only write paths
// - Sends auth headers on every request
// - Throws errors for non-2xx responses
const apiFetch = pipeline(
	fetch,
	f => withTimeout(f, 5000),
	f => withBaseUrl(f, 'https://api.example.com'),
	f => withHeaders(f, {Authorization: 'Bearer token'}),
	withHttpError,
);

const response = await apiFetch('/users');
const data = await response.json();

API

The with* functions are listed in the recommended wrapping order for use with pipeline.

  • is-network-error - Check if a value is a Fetch network error
  • ky - HTTP client based on Fetch
  • parse-sse - Parse Server-Sent Events (SSE) from a Response

Keywords

fetch

FAQs

Package last updated on 08 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts