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 🙏

© 2024 – Pkg Stats / Ryan Hefner

feaxios

v0.0.23

Published

Tiny Fetch wrapper that provides a similar API to Axios

Downloads

10,937

Readme

feaxios

feaxios is a lightweight alternative to Axios, providing the same familiar API with a significantly reduced footprint of 2KB. It leverages the native fetch() API supported in all modern browsers, delivering a performant and minimalistic solution. This makes it an ideal choice for projects where minimizing bundle size is a priority.

Key Features

  • Lightweight: With a size of less than 1/5th of Axios, feaxios is an efficient choice for projects with strict size constraints.

  • Native Fetch API: Utilizes the browser's native fetch, ensuring broad compatibility and seamless integration with modern web development tools.

  • Interceptor Support: feaxios supports interceptors, allowing you to customize and augment the request and response handling process.

  • Timeouts: Easily configure timeouts for requests, ensuring your application remains responsive and resilient.

  • Retries: Axios retry package is integrated with feaxios.

When to Use feaxios

While [Axios] remains an excellent module, feaxios provides a compelling option in scenarios where minimizing dependencies is crucial. By offering a similar API to Axios, feaxios bridges the gap between Axios and the native fetch() API.

npm install feaxios

Request Config

{

url: '/user',

method: 'get', // default

baseURL: 'https://some-domain.com/api/',

transformRequest: [function (data, headers) {
  return data;
}],

transformResponse: [function (data) {

    return data;
}],

headers: {'test': 'test'},

params: {
    ID: 12345
},

 paramsSerializer: {

    encode?: (param: string): string => {},

    serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ),

    indexes: false
  },

  data: {},

  timeout: 1000, // default is 0ms

  withCredentials: false,

  responseType: 'json', // default

  validateStatus: function (status) {
    return status >= 200 && status < 300;
  },

  signal: new AbortController().signal,

  fetchOptions:  {
     redirect: "follow"
  },
 retry: { retries: 3 }

In fetchOptions you can pass custom options like proxy , agents etc supported on nodejs

Usage

import axios from "feaxios";

axios
  .get("https://api.example.com/data")
  .then((response) => {
    // Handle the response
    console.log(response.data);
  })
  .catch((error) => {
    // Handle errors
    console.error(error);
  });

With Interceptors

import axios from "feaxios";

axios.interceptors.request.use((config) => {
  config.headers.set("Authorization", "Bearer *");
  return config;
});
axios.interceptors.response.use(
  function (response) {
    return response;
  },
  function (error) {
    //do something with error
    return Promise.reject(error);
  },
);

Axios Retry Package is also ported to feaxios

import axios from "feaxios"
import axiosRetry from "feaxios/retry"

const http = axios.create({
  timeout: 3 * 1000 * 60,
})

axiosRetry(http, { retryDelay: axiosRetry.exponentialDelay })

Visit: https://github.com/softonic/axios-retry to see more options.