min-req-promise

1.0.1 • Public • Published

Build Status codecov

Minimal Request Promise

request and request-promise are great, but I was looking for an some extra-light implementation.

Usage

client.<get|post|put|delete|head>(url, [options])

  • url The full url to request
  • options an http.request options object. Can be extended with a body attribute.

response: An http.IncomingMessage object, complemented with a body attribute containing the response body data;

const client = require('min-req-promise');
 
return client.get('https://some/url')
  .then(response => {
    // response is an http.IncomingMessage
    // with an extra `body` member
    
    console.log(response.headers);
    console.log(response.body);
  });

Posting data

POST|PUT,.. body can be injected in options.body:

const client = require('min-req-promise');
 
return client.post('http://some/url', {
  headers: {
    'Content-type': 'application/x-www-form-urlencoded'
  },
  body: 'foo=bar'
})
  .then(response => {
    console.log(response);
  });

Readme

Keywords

none

Package Sidebar

Install

npm i min-req-promise

Weekly Downloads

445

Version

1.0.1

License

Apache-2.0

Unpacked Size

26 kB

Total Files

9

Last publish

Collaborators

  • ______b