Skip to content

A minimalistic HTTP client designed for effortless and asynchronous requests.

License

Notifications You must be signed in to change notification settings

mirza7860/quick-fetch-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quick-fetch-api

npm version npm license

quick-fetch-api is a minimalistic HTTP client designed for effortless and asynchronous requests. It offers a straightforward interface, streamlining HTTP operations for a seamless developer experience.

Features

  • Easy Integration: Simplifies making HTTP requests with a clean and intuitive interface.
  • Asynchronous: Utilizes asynchronous operations, allowing for efficient non-blocking requests.
  • Loading State: Provides a loading state indicator to manage asynchronous requests more effectively.
  • Customizable: Provides flexibility for customizing headers, methods, and request data.
  • Higher-Level Abstraction: Includes the EasyFetch class for a more user-friendly approach to handling HTTP requests.

Installation

Install the package using npm:

npm install quick-fetch-api

Usage :

const EasyFetch = require('quick-fetch-api');

// Example usage
const apiUrl = 'https://api.example.com';
const api = new EasyFetch(apiUrl, {
  'Content-Type': 'application/json',
  // Add headers if any
});

// GET request example
api.get({
  url: '/data',
  callback: ({ loading, data, error }) => {
    if (loading) {
      console.log('Loading...');
    } else if (data) {
      console.log('Data:', data);
    } else {
      console.error('Error:', error);
    }
  },
});

// POST request example
const postData = { key: 'value' };
api.post({
  url: '/create',
  data: postData,
  callback: ({ loading, data, error }) => {
    if (loading) {
      console.log('Loading...');
    } else if (data) {
      console.log('Response:', data);
    } else {
      console.error('Error:', error);
    }
  },
});

// {like that you can do PUT,PATCH,DELETE}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Feel free to modify or enhance it further based on your specific project details.