0.6.2 • Published 5 years ago

littlerequester v0.6.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Littlerequester

Build Status npm version

Description

Simple NodeJS HTTP/HTTPS request module with no dependency
Support GET, POST, PUT, PATCH, DELETE request type

Test

Tested for NodeJS 4, 5 and 6

Installation

$ npm i littlerequester --save

Usage

With just a string

const littlerequester = require("littlerequester");

// Make a request to example.com
// you can also directly get json like this -> littlerequester("http://example.com/", "json")
littlerequester("http://example.com/").then(data => {
    // Get raw Data
    console.log(data.data);
    // Get node http response object
    console.log(data.res);
}, e => {
    console.log(e);
})

Or with a more complex object

const littlerequester = require("littlerequester");

// Make a request to example.com
littlerequester({url: "http://example.com/", type: "raw"}).then(data => {
    // Get raw Data
    console.log(data.data);
    // Get node http response object
    console.log(data.res);
}, e => {
    console.log(e);
})

Or

const littlerequester = require("littlerequester");

littlerequester({url: "https://example.com/", type: "json"}).then(data => {
  // Get json Data
  console.log(data.data);
  // Get node http response object
  console.log(data.res);
}, e => {
    console.log(e);
});

littlerequester argument doc

2 params

  • url - String : An url
  • type? - String : json or raw (default to raw) - Optional

OR

param - Object : options An object with the following fields :

  • url - String : Request url
  • type - String : Return data type either json or raw
  • headers - Object : Object with header to use in request (ex: user-agent)
  • method? - String : GET, POST, PUT, PATCH, DELETE default to GET if not provided - Optional
  • data? - Object : Valid Object for POST, PUT and PATCH request - Optional

Release History

  • 0.5.0 add 2nd arg (type - Optional) for request with just a string
  • 0.4.0 add request with just an url
  • 0.3.0 add POST, PUT, PATCH, DELETE request type
  • 0.2.0 Add headers support
  • 0.1.0 Initial release
0.6.2

5 years ago

0.6.1

5 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.5

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago