Fetch Fun is a lightweight library for making HTTP requests using the Fetch API. It provides a simple and intuitive interface for performing various types of HTTP requests, handling responses, and managing configurations.
To install Fetch Fun, use npm or pnpm:
npm install fetch-funor
pnpm add fetch-funHere is a basic example of how to use Fetch Fun:
import * as ff from 'fetch-fun';
// Create a reusable client with base configuration
const client = ff.create()
.pipe(ff.baseUrl, 'https://api.example.com')
.pipe(ff.header, 'Content-Type', 'application/json');
// Make a GET request
const users = await client
.pipe(ff.url, '/users')
.pipe(ff.fetchJSON);
// Make a POST request with JSON body
const newUser = await client
.pipe(ff.url, '/users')
.pipe(ff.method, 'POST')
.pipe(ff.jsonBody, { name: 'John', email: 'john@example.com' })
.pipe(ff.fetchJSON);
// With retry and timeout
const data = await client
.pipe(ff.url, '/data')
.pipe(ff.retry, 3)
.pipe(ff.signal, AbortSignal.timeout(5000))
.pipe(ff.fetchJSON);We welcome contributions to Fetch Fun! If you have any ideas, suggestions, or bug reports, please open an issue on our GitHub repository.
To contribute code, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes and commit them (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
Please ensure your code adheres to our coding standards and includes appropriate tests.
This project is licensed under the MIT License.