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

@austinbreslin/fetcher

v1.0.0

Published

<!--toc:start-->

Readme

Fetcher: A wrapper around Fetch for convenience

Fetcher is a library built on top of fetch API to make http requests in your web applications. It provides similar APIs to fetch, but doesn't require as much boilerplate code.

Why use fetcher?

Simplicity

Fetcher makes it easier to perform HTTP requests in your JavaScript or TypeScript projects. It abstracts away the complexities of the fetch API, allowing you to focus on writing your application's logic without worrying about low-level details. You also don't have to check if the HTTP Request was OK either.

Error Handling

Unlike fetch, Fetcher doesn't throw errors. Instead, it resolves a promise with an error (if there is one) and the result of the request. This makes it easier to handle errors in your application's code.

Features

Fetcher supports all methods provided by the fetch API: GET, POST, PUT, PATCH, and DELETE. It also supports response formats such as JSON, text, blob, bytes, form data, array buffer, and cloned responses. Fetcher has more features than the fetch API.

Extra Features

TypeScript Support

Fetcher is fully supported in TypeScript, allowing you to take advantage of TypeScript's powerful type checking features. This helps catch errors at compile time and makes your code more robust.

Modules

Fetcher is available as both CommonJS and ES modules, making it easy to use in a variety of project setups. The packaged size is around 3kb, npm reports the TS definitions, both types of modules.

Timeout option

Fetcher has a timeout option available for all requests.

import { fetcher } from "@austinbreslin/fetcher";

// One second time limit. If time excedes limit, error will have a value.
const [error, result] = await fetcher("https://example.com", {
    timeoutOptions: {
        timeoutEnabled: true,
        timeLimitMs: 1000 
    }
});

Fetch implementation

Fetcher allows you to supply your own implementation of the Fetch API. The reason for this is because in NodeJS, you might have a scenario where you have to change some HTTP details for CORS or some other reason. Fetcher doesn't want to prevent you from making an HTTP changes that you require.

There is a another effect of this, if you use an old version of NodeJS that doesn't have the Fetch API, you can pass in a polyfilled implementation of that and still recieve all the goodnees of Fetcher. While possible, Fetcher cannot support that polyfill, as it could deviate from the Standard, so be particular about your package selections, if there is a standard please try to find a package that most accurately follows that standard.

JSON Parse implementation

Fetcher allows you to supply your own implementation of JSON parsing. This was added because the standard JSON parse built into browsers/NodeJS works funny at best. So you might want to use a different parser, such as @austinbreslin/safe-json

Installation

You can install Fetcher using npm:

npm install --save @austinbreslin/fetcher

Or pnpm:

pnpm install @austinbreslin/fetcher 

Usage

Here's an example of how to use Fetcher to make a GET request:

import { fetcher } from '@austinbreslin/core-utils';

const [error, result] = await fetcher.get('https://jsonplaceholder.typicode.com/posts/1').json()
console.log({ error, result });

This will make a GET request to https://jsonplaceholder.typicode.com/posts/1, and print the response data to the console. If there is an error, it will be logged to the console instead.

Dependencies

  • Pledge - Wraps promises preventing a lot of boilerplate code