node-xhr

Asynchronous HTTP request utility for node, just like XMLHttpRequest.

Usage no npm install needed!

<script type="module">
  import nodeXhr from 'https://cdn.skypack.dev/node-xhr';
</script>

README

node-xhr

Asynchronous HTTP request utility for node, just like XMLHttpRequest.

var xhr = require('node-xhr');

xhr.post({
    url     : 'http://localhost:3000/v1/test',
    headers : {
        'Content-Type' : 'application/json',
    },
    params  : {
        // ...
    },
    body    : {
        // ...
    },
}, function(err, res) {
    if (err) {
        console.log(err.message);
        return;
    }

    console.log(JSON.stringify(res.status));
    console.log(JSON.stringify(res.headers));
    console.log(res.body);
});

Installation

You can install it by npm install node-xhr.

Documentation

About more details, please see API doc.

License

The code under The MIT License