Socket
Book a DemoInstallSign in
Socket

small-request

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

small-request

A thin Promise wrapper around Node.js http/https request functions

2.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

small-request

npm version Build Status codecov

This Node.js module is a thin wrapper around the Node.js http/https request functions that provides:

  • A Promise interface
  • Handling of response chunking
  • Auto-selection of the http/https request function

The promise is resolved when:

  • A response is received from the server regardless of status code

The promise is rejected when:

  • Any other exception is encountered

Example usage:

const request = require('small-request');

request.send({
  url: 'https://httpbin.org/get'
}).then(response => {
  console.log(response.body);
});

RequestModel

The request.send(requestModel) function takes in a requestModel object. This object is an extended version of the Node.js http.request options object. Its extended fields are:

  • url (string)
  • body (string)
  • socketTimeout (number in milliseconds)

If the original http.request option field values conflict with the extended field values, then the original field values take precedence.

ResponseModel

The promise returned by request.send() resolves to an object with the following fields:

  • body (string)
  • headers (object)
  • statusCode (number)

Keywords

promise

FAQs

Package last updated on 15 Sep 2018

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.