1.9.6 • Published 2 months ago

@siberiacancode/fetches v1.9.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

🔮 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 {
  page: number;
  limit: number;
}

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

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.9.1

5 months ago

1.7.3

6 months ago

1.9.0

5 months ago

1.8.1

6 months ago

1.7.2

6 months ago

1.8.0

6 months ago

1.7.1

6 months ago

1.7.0

6 months ago

1.6.0

6 months ago

1.5.0

6 months ago

1.4.0

6 months ago

1.3.1

8 months ago

1.2.2

8 months ago

1.1.3

8 months ago

1.3.0

8 months ago

1.2.1

8 months ago

1.1.2

8 months ago

1.9.6

2 months ago

1.9.5

4 months ago

1.9.4

4 months ago

1.9.3

4 months ago

1.9.2

5 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago