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

@mynopkg/mini-fetch

v0.2.1

Published

A minimal TypeScript fetch wrapper for API calls

Downloads

251

Readme

@mynopkg/mini-fetch

A minimal, type-safe fetch wrapper with timeout, response type parsing, and structured error handling.

Features

  • Automatic JSON serialization for request body
  • Multiple response types: json, text, blob, arrayBuffer
  • Configurable timeout with AbortController
  • External AbortSignal support
  • Structured error classes: HttpError, TimeoutError, RequestError
  • ESM and CJS dual build

Requirements

  • Node.js >= 20

Installation

npm install @mynopkg/mini-fetch

Usage

miniFetch — core function

import { miniFetch } from '@mynopkg/mini-fetch'

const res = await miniFetch<{ id: number; title: string }>('https://api.example.com/todos/1')
console.log(res.data) // { id: 1, title: '...' }

Response types

const json = await miniFetch<MyType>(url, { responseType: 'json' }) // default
const text = await miniFetch<string>(url, { responseType: 'text' })
const blob = await miniFetch<Blob>(url, { responseType: 'blob' })
const buffer = await miniFetch<ArrayBuffer>(url, { responseType: 'arrayBuffer' })

Timeout

await miniFetch(url, { timeout: 3000 }) // throws TimeoutError after 3s

Custom AbortSignal

const controller = new AbortController()

// Abort the request manually
setTimeout(() => controller.abort(), 5000)

try {
  await miniFetch(url, { signal: controller.signal })
} catch (e) {
  if (e instanceof RequestError) {
    console.log('Request was aborted')
  }
}

POST with body

// Plain objects are automatically serialized to JSON
await miniFetch(url, {
  method: 'POST',
  json: { name: 'Jane Doe' },
})

// FormData, Blob, ArrayBuffer are passed as body
await miniFetch(url, {
  method: 'POST',
  body: new FormData(),
})

miniFetchClient — pre-configured instance with helper methods

import { miniFetchClient } from '@mynopkg/mini-fetch'

const res = await miniFetchClient.get<User[]>('https://api.example.com/users')
await miniFetchClient.post('https://api.example.com/users', { json: { name: 'Jane Doe' } })

// Create a new client instance with baseUrl
const api = miniFetchClient.create('https://api.example.com')
await api.get<User[]>('/users')
await api.post('/users', { json: { name: 'Jane Doe' } })
await api.delete('/users/1')

MiniFetchClient — custom client with baseUrl

import { MiniFetchClient } from '@mynopkg/mini-fetch'

const api = new MiniFetchClient('https://api.example.com')

await api.get<User[]>('/users')
await api.post('/users', { json: { name: 'Jane Doe' } })
await api.delete('/users/1')

Error Handling

import { miniFetch, HttpError, TimeoutError, RequestError } from '@mynopkg/mini-fetch'

try {
  await miniFetch('https://api.example.com/users')
} catch (e) {
  if (e instanceof HttpError) {
    console.log(e.status) // 404, 500, etc.
    console.log(e.method) // 'GET'
    console.log(e.url)
  } else if (e instanceof TimeoutError) {
    console.log(e.timeout) // ms
  } else if (e instanceof RequestError) {
    console.log(e.message)
  }
}

Options

| Option | Type | Default | Description | | -------------- | --------------------------------------- | -------------- | ----------------------- | | method | GET \| POST \| PUT \| PATCH \| DELETE | GET | HTTP method | | body | any | — | Request body | | headers | HeadersInit | — | Request headers | | responseType | json \| text \| blob \| arrayBuffer | json | Response parsing type | | timeout | number | 0 (disabled) | Timeout in milliseconds | | signal | AbortSignal | — | External abort signal |

License

ISC

Contributing

Issues and pull requests are welcome! If you find a bug or have a feature request, please open an issue on GitHub.