regular-requestdeprecated

Implementation of a wrapper to simplify operation with a built-in object 'http.request'

Usage no npm install needed!

<script type="module">
  import regularRequest from 'https://cdn.skypack.dev/regular-request';
</script>

README

regular-request

Implementation of a wrapper to simplify operation with a built-in object 'http.request'. The main motive for the development of this project was to use only the built-in node.js modules.

Install

npm install regular-request

Options

  • options - can be a string (url) or an object. A full description of the fields see here. Options can also contain:
    • url - the optional value, can be a string (url); If set, after parsing all the conflicting values will be overwritten with an explicit value of the object 'options'
    • body - the optional value to write to the request body;
    • check - the optional function for check the result of the query (response) before passing it on;
  • done - An optional callback function. Can return two arguments error and result (IncomingMessage). If an error occurs, the result is not returned, only error. If callback is present, but the instance of the object has no pipes, the result is returned in the callback. If callback is present, and there are pipes, in any case the result is returned in the pipe only. If there is no callback, processing errors possible on "error" listener of this object.

Example

An example of a POST-request

var request = require('regular-request');
var link = 'http://httpbin.org/post';
var data = 'Hello world';
request.post(link, data).pipe(process.stdout);

License

MIT