Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

satvik-s/http2-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d3fba75 · Jul 8, 2021

History

8 Commits
Jul 8, 2021
Jul 5, 2021
Jul 8, 2021
Jul 8, 2021
Jul 8, 2021
Jul 5, 2021
Jul 5, 2021
Jul 5, 2021
Jul 5, 2021
Jul 5, 2021
Jul 5, 2021
Jul 5, 2021
Jul 5, 2021
Jul 8, 2021
Jul 5, 2021
Jul 8, 2021
Jul 5, 2021
Jul 8, 2021
Jul 8, 2021
Jul 5, 2021

Repository files navigation


http2-client

npm David node-current Snyk Vulnerabilities GitHub

An opinionated HTTP/2 wrapper around native NodeJS module

http2-client provides a simple and accessible interface to make HTTP/2 requests to servers.

How it works

The Http2Client class provides ability to the user to create instances of an HTTP/2 client which can then be leveraged to call single/multiple APIs, single/multiple times over its lifetime.

Examples

GET Request

import { Http2Client } from '@satvik-s/http2-client';

const client = new Http2Client('https://test-service.com');
const resp = await client.request({
    method: 'GET',
    scheme: 'https',
    path: '/v1/test-api',
});

console.log('status', resp.statusCode);
console.log('body', resp.body);
console.log('headers', resp.headers);

POST Request

import { Http2Client, PayloadType } from '@satvik-s/http2-client';

const client = new Http2Client('https://test-service.com');
const resp = await client.request({
    method: 'POST',
    scheme: 'https',
    path: '/v1/test-api',
    body: {
        type: PayloadType.JSON,
        data: {
            hello: 'world',
        }
    },
});

console.log('status', resp.statusCode);
console.log('body', resp.body);
console.log('headers', resp.headers);

Contributing

Contributions are welcome! Read CONTRIBUTING.md for more details.