Skip to content

wmzy/fetch-fun

Repository files navigation

Fetch Fun

npm version Build Status Coverage Status

Table of Contents

Description

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.

Installation

To install Fetch Fun, use npm or pnpm:

npm install fetch-fun

or

pnpm add fetch-fun

Usage

Here 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);

Contributing

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:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes and commit them (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

Please ensure your code adheres to our coding standards and includes appropriate tests.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors