1.1.0 • Published 7 years ago
bellmounte-http-request v1.1.0
http-request
A Promise wrapper around the native node http.request
and https.request
methods.
Usage
const options = {
hostname: 'example.com',
port: 80,
path: '/api',
method: 'POST',
};
const data = JSON.stringify({
sample: 'test'
});
httpRequest(options, data).then((response) => {
console.log({response});
}).catch((error) => {
console.error({error});
});
Note: options
follows the nodejs's method for http.request.
Additional Options
followAllRedirects
- Follows redirects from http status code 301.