1.0.1 • Published 2 years ago

amirhnajafiz21-http-client v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

HTTP Client

Make easy HTTP requests with JavaScript.

How to use?

First install the latests version of package:

npm i --save amirhnajafiz21-http-client

After that create a HTTP client and fetch your requests.

// importing http client
import HTTPClient from "amirhnajafiz21-http-client";

// creating a new http client
const httpClient = new HTTPClient();

get

let fetchGetRequest = httpClient.fetchGetRequest("https://jsonplaceholder.typicode.com/todos/1");
fetchGetRequest.then((json) => {
    console.log(json);
});

post

let fetchPostRequest = httpClient.fetchPostRequest("https://jsonplaceholder.typicode.com/todos", {
    id: 1,
    title: "Hello",
});
fetchPostRequest.then((json) => {
    console.log(json);
});

patch

let fetchPatchRequest = httpClient.fetchPatchRequest("https://jsonplaceholder.typicode.com/todos/1", {});
fetchPatchRequest.then((json) => {
    console.log(json);
});

put

let fetchPutRequest = httpClient.fetchPutRequest("https://jsonplaceholder.typicode.com/todos/1", {});
fetchPutRequest.then((json) => {
    console.log(json);
});

delete

let fetchDeleteRequest = httpClient.fetchDeleteRequest("https://jsonplaceholder.typicode.com/todos/1");
fetchDeleteRequest.then((json) => {
    console.log(json);
});