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

fetchcustom-vsm

v3.0.1

Published

Simple fetch custom

Downloads

5

Readme

FetchCustom README

Introduction

FetchCustom is a lightweight wrapper for the native fetch API in Node.js, providing additional functionality for handling HTTP requests and responses. It is designed to simplify the request process, especially when dealing with JSON, text, or blob data. This utility leverages the resolve pattern and requires Node.js 18 due to the native fetch support introduced in this version.

Features

  • JSON Serialization: Automatically serializes request bodies if they are plain objects or arrays.
  • Custom Error Handling: Provides a ResponseError class for detailed error messages, including HTTP status codes and status text.
  • Data Parsing: Supports methods for parsing responses as JSON, text, or blobs.
  • Resolve Pattern: Uses the resolve pattern to handle success and error states more gracefully.

Requirements

  • Node.js 18+: This library relies on the native fetch API, which is available from Node.js 18.

Usage

npm i fetchcustom-vsm

Import and Setup

import { FetchCustom } from './fetchcustom-vsm';

Example Request

const fetcher = new FetchCustom();

async function makeRequest() {
  const response = await fetcher.fetchCustom('https://api.example.com/data', {
    method: 'POST',
    body: { key: 'value' },
  });

  const result = await response.toJson();
  if (result.error) {
    console.error('Error:', result.error);
  } else {
    console.log('Data:', result.data);
  }
}

makeRequest();

toJson<T>(): Promise<{ data: T | undefined; error: Error | undefined }>

This method parses the response as JSON and returns the data or error.

Example:

const result = await fetcher.toJson();
if (result.error) {
  console.error('Error:', result.error);
} else {
  console.log('Data:', result.data);
}

toText<T>(): Promise<{ data: T | undefined; error: Error | undefined }>

This method parses the response as plain text.

Example:

const result = await fetcher.toText();
if (result.error) {
  console.error('Error:', result.error);
} else {
  console.log('Text:', result.data);
}

toBlob<T>(): Promise<{ data: T | undefined; error: Error | undefined }>

This method parses the response as a blob.

Example:

const result = await fetcher.toBlob();
if (result.error) {
  console.error('Error:', result.error);
} else {
  console.log('Blob:', result.data);
}

Error Handling

If the fetch request returns a non-OK status (HTTP status code outside the 2xx range), the library throws a `ResponseError` with details such as `statusText` and `statusCode`.

🌐 Important Links

-Homepage: https://github.com/Smejia11/FetchCustom

-Repository: git+https://github.com/Smejia11/FetchCustom.git

-Issues: https://github.com/Smejia11/FetchCustom/issues

🤝 Contributing

Contributions are welcome.

Fork the project

Create your feature branch (git checkout -b feature/AmazingFeature)

Execute

npm run format

or

pnpm run format

Commit your changes (git commit -m 'Add some AmazingFeature')

Push to the branch (git push origin feature/AmazingFeature)

Open a Pull Request

License

MIT