🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@siberiacancode/fetches

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@siberiacancode/fetches

fetch instance

latest
Source
npmnpm
Version
1.13.1
Version published
Maintainers
1
Created
Source

đź”® fetches

A lightweight and flexible HTTP client for making API requests, inspired by Axios.

Installation

npm install @siberiacancode/fetches

Usage

import fetches from '@siberiacancode/fetches';

const response = await fetches.get<User[]>('/users');

Custom instance

const api = fetches.create({
  baseURL: 'https://api.example.com',
  headers: {
    'Content-Type': 'application/json'
  }
});

api.interceptors.request.use(
  (config) => {
    config.headers.Authorization = 'Bearer token';
    return config;
  },
  (error) => Promise.reject(error)
);

Request wrapper

interface GetUsersParams {
  limit: number;
  page: number;
}

const getUsers: ApiFetchesRequest<GetUsersParams, any[]> = ({ params, config }) =>
  fetches.get('/users', {
    ...config,
    params: { ...config?.params, ...params }
  });

Response parse

The fetches library provides flexible response parsing options to handle different types of responses. You can specify how to parse the response body using predefined modes or custom functions. If no parse mode is specified, the response will be automatically parsed based on the Content-Type header:

const response = await fetches.get('/users', { parse: 'json' });

Custom parse functions

You can provide a custom function that takes a Response object and returns a Promise with parsed data. This is useful for handling special response formats or custom parsing logic.

const response = await fetches.get('/users', { parse: (data) => data.json() });

Raw response

To get the raw response body without any parsing, use the 'raw' parse mode. This is useful when you need to handle the response manually or when working with binary data.

const response = await fetches.get('/binary-file', { parse: 'raw' });

Base URL

You can set the base URL when creating a new instance:

import { Fetches } from '@siberiacancode/fetches';

const api = new Fetches({
  baseURL: '/api'
});

await api.get('/users'); // /api/users

You can override the base URL for individual requests using the baseURL option:

await api.get('/users', { baseUrl: '/api' });

Context

The library supports a context system that allows you to pass data through the entire request lifecycle.

const response = await fetches.get('/users', { context: 'data' });

console.log('response', response.options.context); // 'data'

Keywords

fetch

FAQs

Package last updated on 05 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts