1.0.0 • Published 8 months ago
custom-http-wrapper v1.0.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);
});
1.0.0
8 months ago