1.0.1 • Published 3 years ago

hreq v1.0.1

Weekly downloads
2,406
License
ISC
Repository
-
Last release
3 years ago

hreq

A minimal http request client.

Install

npm install hreq

Usage

The module returns a single function:

hreq = require( "hreq" )

It takes an options argument which with the same format as described for the built in Node.js https.request() function. In addition, it takes a two callback functions, the first will be called on success with the body of the response, and the second will be called with an error if there was a problem:

hreq( options[, callback_success[, callback_failure ] )

An attribute called "url" is expected to be in the options object:

options = { url: "https://google.com" }

The url is passed as the first argument to https.request() and the full options object is passed as the second argument.

hreq( options, html => {
	console.log( "Google HTML is: " + html );
}, err => {
	console.error( err );
});