@allgemein/http

1.2.0 • Public • Published

@allgemein/http

Build Status codecov Dependency Status

This is a abstract implementation for a generic http requests api, which can be backed by different implementations. Like got, request, node-fetch or others.

The default implementation is uses got package.

Install

npm i @allgemein/http got

Usage

import {HttpFactory, IHttpResponse, IHttp, IHttpStream} from "commons-http";

let httpFactory = await HttpFactory.load();
let http:IHttp = httpFactory.create();

// use as promise
let resp:IHttpResponse<any> = await http.get('http://example.com');
console.log(resp.body)

// use as stream
let stream:IHttpStream<any> = http.get('http://example.com',{stream:true});
stream.pipe(fs.createWriteStream('test.file'));

await stream.asPromise()

/@allgemein/http/

    Package Sidebar

    Install

    npm i @allgemein/http

    Weekly Downloads

    3

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    49 kB

    Total Files

    57

    Last publish

    Collaborators

    • cezaryrk