light-req

0.0.5 • Public • Published

light-req NPM version Build Status Code Coverage install size

A very tiny package (zero dependencies) that allows you to make http and https requests (some wrap and sugar for nodejs http and https)

Install

$ npm install light-req

Usage

Some arguments are optional, but you can not skip them, you should use undefined instead of correct values, except they are last

makeHttpRequest function arguments

  • isSecure - false if you want http, true if you want https, boolean, required
  • url - string with host and port, with or without protocol, string, required
  • login - base auth user, string, optional
  • password - base auth password, string, optional
  • method - http method, string, required
  • path - path to resource (if you want to explicit type conversion from string for environment variables), string, required
  • body - json body object, optional
  • options - you can specify most of http and https options, object, optional
  • doNotReadResponse - set to true if you want to read response stream yourself, boolean, optional

Example

const makeHttpRequest = require("light-req");

const actualResult = await makeHttpRequest(
        false,
        "http://127.0.0.1:3000",
        "user",// or undefined
        "pass",// or undefined
        "POST",
        "/test_route",
        {request: 1},// or undefined
        { timeout: 20000 },// or undefined
        true,// or undefined
    );

Readme

Keywords

Package Sidebar

Install

npm i light-req

Weekly Downloads

0

Version

0.0.5

License

ISC

Unpacked Size

6.49 kB

Total Files

3

Last publish

Collaborators

  • v-electrolux