1.0.1 • Published 6 years ago
riquest v1.0.1
riquest
Zero dependency node.js http(s) request library.
Installation
npm i -s riquestUsage
Simple use the arrandomize function with an array:
const riquest = require('riquest')
riquest({
url: 'https://swapi.co/api/people/',
headers: {
accept: 'application/json',
},
method: 'get',
timeout: 3000,
returnStream: false,
})
.then(console.log)
.catch(console.error)API
riquest(params)
Performs a http/http request using http/https base node libraries.
Parameters
params: Params for http/https riquest.params.url: The full url to riquest. REQUIREDparams.headers: An object of key/value headers. Defaults areAccept: application/json&Content-Type: application/jsonparams.method: The method to use to query url.params.data: An object of key/value representing the body json which will be sent along with query.params.timeout: A number of milliseconds before the query returns a timeout error.params.returnStream: A boolean controlling whether riquest should return an object or a stream (useful when piping is needed, like for streaming response).
Other params are available.
params.authparams.agentparams.createConnectionparams.caparams.certparams.keyparams.rejectUnauthorized
Please see node http.request documentation for more informations on those params.
Return value
A promise that returns an object representing the response json. If returnStream option is set to true, the promise return will be a stream.
Exceptions
Thows an Error when any param is not of expected format, or when actual query fails.
License
MIT license. Copyright ©2019.