Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fetch-extras

sindresorhus3.3kMIT1.0.0TypeScript support: included

Useful utilities for working with Fetch

fetch, whatwg, api, request, response, http, client, httperror, utilities, wrapper, ky, got, axios

readme

fetch-extras logo

Useful utilities for working with Fetch

For more features and conveniences on top of Fetch, check out my ky package.

Install

npm install fetch-extras

Usage

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

// Create an enhanced reusable fetch function that:
// - Throws errors for non-200 responses
// - Times out after 5 seconds
const enhancedFetch = withHttpError(withTimeout(fetch, 5000));

const response = await enhancedFetch('/api');
const data = await response.json();

API

See the types for now.

  • is-network-error - Check if a value is a Fetch network error
  • ky - HTTP client based on Fetch