npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@toteat-eng/toteat-fetch

v0.2.1

Published

Minimal fetch-based HTTP client with axios-compatible API surface

Readme

@toteat-eng/toteat-fetch

Minimal fetch-based HTTP client with an axios-compatible API surface. Zero external dependencies — uses native fetch.

Install

npm install @toteat-eng/toteat-fetch

Usage

import { createHttpClient } from '@toteat-eng/toteat-fetch';

const client = createHttpClient({
  baseURL: 'https://api.example.com',
  headers: { Authorization: 'Bearer token' },
  timeout: 10000, // ms, default 30000
});

const response = await client.get<User>('/users/1');
console.log(response.data); // typed as User

API

createHttpClient(config?)

Creates a new HTTP client instance.

| Option | Type | Default | Description | |---|---|---|---| | baseURL | string | '' | Base URL prepended to all request paths | | headers | Record<string, string> | {} | Default headers for all requests | | timeout | number | 30000 | Request timeout in milliseconds | | credentials | RequestCredentials | — | Credentials mode ('include', 'same-origin', 'omit') |

Methods

client.get<T>(url, config?)
client.post<T>(url, data?, config?)
client.put<T>(url, data?, config?)
client.patch<T>(url, data?, config?)
client.delete<T>(url, config?)

All methods return Promise<FetchResponse<T>>:

interface FetchResponse<T> {
  data: T;
  status: number;
  headers: Record<string, string>; // keys are lowercased
}

Per-request config

interface RequestConfig {
  params?: Record<string, string | number | boolean | null | undefined | Array<...>>;
  headers?: Record<string, string>;
  validateStatus?: (status: number) => boolean;
  signal?: AbortSignal; // per-request cancellation
}

Errors

All errors are HttpClientError:

import { HttpClientError } from '@toteat-eng/toteat-fetch';

try {
  await client.get('/users/1');
} catch (err) {
  if (err instanceof HttpClientError) {
    console.log(err.message);            // "Request failed with status code 404"
    console.log(err.response?.status);   // 404
    console.log(err.response?.data);     // parsed response body
    console.log(err.cause);              // original fetch error (network errors)
  }
}

Interceptors

// Request interceptor — modify config before fetch
const id = client.interceptors.request.use(
  (config) => {
    config.headers['X-Request-Id'] = crypto.randomUUID();
    return config;
  },
  (error) => Promise.reject(error), // optional error handler
);

// Response interceptor — transform response
client.interceptors.response.use(
  async (response) => {
    // supports async
    return response;
  },
  async (error) => {
    // recover from errors or re-throw
    throw error;
  },
);

// Remove interceptor
client.interceptors.request.eject(id);

Cancellation

const controller = new AbortController();

client.get('/slow-endpoint', { signal: controller.signal });

// Cancel
controller.abort();

Note: When you provide signal, the client-level timeout is not applied — your signal is used directly. If you need both cancellation and a timeout, combine them yourself:

const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(5000)]);
client.get('/slow-endpoint', { signal });

Axios compatibility

Drop-in for the axios subset used in toteat projects:

| Feature | Support | |---|---| | response.data | ✅ | | interceptors.request.use / .eject | ✅ | | interceptors.response.use / .eject | ✅ | | HttpClientError.response | ✅ | | validateStatus | ✅ | | Async interceptors | ✅ | | baseURL | ✅ | | Query params (params) | ✅ | | FormData / Blob / ArrayBuffer bodies | ✅ |

Requirements

  • Node >= 20
  • Native fetch available (Node 18+, all modern browsers)