nitro-http-client
v1.0.8
Published
A HTTP client module I made because I can't deal with other modules
Downloads
6
Readme
nitro-http-client
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);