npm.io
1.0.0 • Published 2 years ago

custom-http-wrapper

Licence
ISC
Version
1.0.0
Deps
4
Size
15 kB
Vulns
0
Weekly
0

CustomHTTP

CustomHTTP is a lightweight HTTP client library for making HTTP requests in JavaScript using XMLHttpRequest.

Installation

You can install the library using npm:

npm install custom-http

Usage

Importing
import { CustomHTTP } from 'custom-http';
import { HttpMethod } from 'custom-http/constants/httpMethods';
Creating an instance
const http = new CustomHTTP();

Examples

Making a GET request
customHTTP.get('https://jsonplaceholder.typicode.com/posts/1') // Первый запрос
    .then((response) => {
        console.log('GET Response:', response);
    })
    .catch((error) => {
        console.error('GET Error:', error);
    });
Making a Patch request
customHTTP.patch('https://jsonplaceholder.typicode.com/posts/1', {
title: 'title',
body: 'body'
}) // Первый запрос
.then((response) => {
console.log('PATCH Response:', response);
})
.catch((error) => {
console.error('PATCH Error:', error);
});