Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

light-req

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

light-req

nodejs http and https lightweight wrapper for easy requests

latest
Source
npmnpm
Version
0.0.5
Version published
Weekly downloads
9
28.57%
Maintainers
1
Weekly downloads
 
Created
Source

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
    );

Keywords

http

FAQs

Package last updated on 11 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts