Callarest
A simple tool to natively make http(s) requests in node
Example Usage
Verbose
const callarestJson = require('callarest/json')
callarestJson({
method: 'post',
data: JSON.stringify({ hello: 'world' }),
headers: {
'Content-Type': 'application/json'
},
url: 'https://www.example.com'
}, function (error, rest) {
if (error) {
console.log('There was an error:', error);
}
console.log('The request was:', rest.request);
console.log('The response was:', rest.response);
console.log('The body was:', rest.body);
})
JSON
const callarest = require('callarest')
callarest.json({
method: 'post',
data: { hello: 'world' },
url: 'https://www.example.com'
}, function (error, rest) {
if (error) {
console.log('There was an error:', error);
}
console.log('The request was:', rest.request);
console.log('The response was:', rest.response);
console.log('The body was:', rest.body);
})
License
This project is licensed under the terms of the MIT license.