1.0.2 • Published 7 months ago

aync-http-request-package v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

What is this?

This is a simple npm package that provides a reusable asynchronous HTTP request function for making HTTP requests using Axios. It supports GET, POST, PUT, and DELETE HTTP methods.

Installation

To install this package in your project, run the following command:

npm i aync-http-request-package

Usage

Importing the Package

import { get, post } from 'async-http-request-package;

Making HTTP Requests

Use the customeRequest function to make HTTP requests with flexibility:

const url = 'https://api.example.com/data';
const method = 'GET'; // Replace with 'POST', 'PUT', or 'DELETE' if needed
const data = { key: 'value' }; // Optional data for POST or PUT requests

(async () => {
  try {
    const response = await customeRequest(url, method, data);
    console.log('Response:', response);
  } catch (error) {
    console.error('Error:', error);
  }
})();

Customization

You can customize your requests by passing additional parameters to the customeRequest function, such as headers, query parameters, or authentication tokens:

  headers: {
    'Authorization': 'Bearer your_access_token',
    'Custom-Header': 'custom-value',
  },
  params: {
    page: 1,
    limit: 10,
  },
};

(async () => {
  try {
    const response = await sendRequest(url, method, data, options);
    console.log('Response:', response);
  } catch (error) {
    console.error('Error:', error);
  }
})();

Licence

This package is released under the MIT License.

In this `README.md`, you provide installation instructions, usage examples, customization options, and mention the license under which your package is distributed. Be sure to replace `'dynamic-http-requests'` with the actual name of your npm package. Additionally, customize the usage examples and descriptions according to the functionality of your package.
1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago