https://github.com/nitrog0d/nitro-http-client
A HTTP client module I made because I can't deal with other modules
https://github.com/nitrog0d/nitro-http-client
http http-client http-request nodejs
Last synced: 10 months ago
JSON representation
A HTTP client module I made because I can't deal with other modules
- Host: GitHub
- URL: https://github.com/nitrog0d/nitro-http-client
- Owner: nitrog0d
- Created: 2021-04-13T16:08:47.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T19:30:45.000Z (about 2 years ago)
- Last Synced: 2025-04-04T09:18:16.346Z (10 months ago)
- Topics: http, http-client, http-request, nodejs
- Language: TypeScript
- Homepage: https://nitro.moe
- Size: 10.7 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nitro-http-client
[](https://www.npmjs.com/package/nitro-http-client)
[](https://patreon.com/nitrog0d)
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**
```js
const { NitroHttpClient } = require('nitro-http-client');
const httpClient = new NitroHttpClient();
```
### TypeScript
**Create the client**
```ts
import { NitroHttpClient } from 'nitro-http-client';
const httpClient = new NitroHttpClient();
```
### Examples
**Example with default values, no body, GET method, no extra headers**
```js
const response = await httpClient.request('https://example.com');
console.log(response.statusCode);
```
**.then example since it returns a Promise**
```js
httpClient.request('https://example.com').then(response => {
console.log(response.body);
});
```
**Example with custom values**
```js
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);
```