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 🙏

© 2025 – Pkg Stats / Ryan Hefner

reqos

v0.0.2

Published

Reqos is a data fetching utility that uses `fetch`. Reqos implements an automatic data parsing approach based on `content-type` which is helpful in speeding up development. It also handle errors better by eliminating the need of implementing `catch` block

Downloads

600

Readme

Reqos

Reqos is a data fetching utility that uses fetch. Reqos implements an automatic data parsing approach based on content-type which is helpful in speeding up development. It also handle errors better by eliminating the need of implementing catch blocks.

Getting Started

Install

npm i reqos@latest

Import

import { FetchClient } from 'reqos';

const client = new FetchClient();
const { data, error } = await client.get('/api/users');

Reqos checks the response content-type and parses the data automatically.

If reqos encounters an error, the data property becomes null and the response is populated in error property. Reqos handles client side malformations as well which can lead to errors sometimes. This eliminates the need of wrapping fetch inside a try...catch block.

Supported methods

client.get(...): Initiates a request with GET method.
client.post(...): Initiates a request with POST method. Helpful in creating new records.
client.put(...): Initiates a request with PUT method. Helpful in replacing existing record.
client.delete(...): Initiates a request with DELETE method. Helpful in deleting existing record.
client.patch(...): Initiates a request with PATCH method. Helpful in modifying existing record.

Creating methods of your own

Reqos provides support for popular fetch methods. However, if users want to use other fetch methods they can always extend the utility.

Supporting standard methods:

import { FetchClient, AssertMethod } from 'reqos';
import type { ReqInit } from 'reqos';

class CustomClient extends FetchClient {
  @AssertMethod()
  async option<D, E>(url: string, options?: ReqInit) {
    return this.__api<D, E>(url, options);
  }
}

AssertMethod decorator wires the method using function name. It checks if the function name is valid or not, then applies the appropriate method while sending browser request.

Supporting non-standard methods:

At this point we are not sure if fetch supports non-standard methods or not (Probably not!). However, users are not limited to using only the standard REST methods. They can do whatever they want!

import { FetchClient } from 'reqos';
import type { ReqInit } from 'reqos';

class CustomClient extends FetchClient {
  async option<D, E>(url: string, options?: ReqInit) {
    return this.__api<D, E>(url, {
      ...options,
      method: 'I_CAN_DO_WHATEVER_I_WANT_METHOD',
    });
  }
}

Disclaimer

Reqos has been released as a proof of concept. Our ultimate goal is to turn this into a library that requires minimal setup and configuration. We encourage users to use this utility in their own projects and report any problems if they face. Users can also use it in production code as well if they want. At any point if the users think that the library did not work as intended, they can always fallback to native fetch (See example below).

const client = new FetchClient();
const response = await client.request('/api/user');

This documentation is a "work in progress". New suggestions and PRs are always welcome.

Roadmap

Upcoming features:

  1. Provide support for abort and retry. Aborting is already supported via AbortController and signal. We want to write our own wrapper that would let us do timeouts and retries.
  2. Provide support for useFetchClient react hook for React projects.
  3. Provide support for unit testing by adding test utilities.