1.0.4 • Published 6 months ago

@caviajs/http-client v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Introduction

This package includes an HttpClient with which you can make HTTP requests.

Usage

Installation

npm install @caviajs/http-client --save

Make an HTTP request

import { HttpClient, HttpResponse } from '@caviajs/http-client';

HttpClient
  .request({
    /* 
      agent?: http.Agent | https.Agent;
      body?: HttpBody;
      headers?: { [key: string]: string | number };
      method: 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT';
      responseType?: 'buffer' | 'stream';
      timeout?: number;
      url: string | URL; 
    */
  })
  .then((response: HttpResponse) => {
    // all http statuses are treated as resolved (1xx-5xx)
    
    // response.body ...
    // response.headers ...
    // response.statusCode ...
    // response.statusMessage ...
  })
  .catch((error: Error) => {
    // only exceptions of the kind, e.g. network errors, are treated as thrown
  });

Request body serialization

The request body that we pass will be automatically serialized in accordance with the specification below.

Response body decompression

If the Content-Encoding header is specified then HttpClient will decompress the response.

Supported decompression: gzip and deflate.

1.0.4

6 months ago

1.0.2

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.3

1 year ago

0.2.4

1 year ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago