Small package that provides a promise-based, stream-oriented wrapper around the http and https modules.
Easy use case: just downloads and prints a page with error handling.
import httpRequestPlus from "http-request-plus";
async function main() {
// this is a standard Node's IncomingMessage augmented with the following method:
//
// - buffer(): returns a promise to the content of the response in a Buffer
// - json(): returns a promise to the content of the response parsed as JSON
// - text(): returns a promise to the content of the response parsed as a UTF-8 string
const response = await httpRequestPlus("http://example.org", {
// A request body can provided, either as a buffer/string or a stream
body: "foo bar",
// By default, http-request-plus throws if the reponse's status Code is not 2xx
//
// This option can be used to bypass this
bypassStatusCheck: true,
// Maximum number of redirects that should be handled by http-request-plus
//
// Defaults to 5
maxRedirects: