Skip to content

A HTTP client module I made because I can't deal with other modules

Notifications You must be signed in to change notification settings

nitrog0d/nitro-http-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nitro-http-client

npm release Support me on Patreon

A HTTP client module I made because I can't deal with other modules
It does not support/handle compression, I'll eventually implement it according to my needs

Installation

  • NPM: npm install nitro-http-client
  • Yarn: yarn add nitro-http-client

Usage

JavaScript

Create the client

const { NitroHttpClient } = require('nitro-http-client');
const httpClient = new NitroHttpClient();

TypeScript

Create the client

import { NitroHttpClient } from 'nitro-http-client';
const httpClient = new NitroHttpClient();

Examples

Example with default values, no body, GET method, no extra headers

const response = await httpClient.request('https://example.com');
console.log(response.statusCode);

.then example since it returns a Promise

httpClient.request('https://example.com').then(response => {
  console.log(response.body);
});

Example with custom values

const response = await httpClient.request('https://example.com', {
  method: 'POST',
  headers: {
    Authentication: '123',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ test: 123 })
});
console.log(response.headers);

About

A HTTP client module I made because I can't deal with other modules

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published