minimal-request
v3.0.0
Published
Like request, but just what I need for doing simple Get/post reqs
Downloads
6,920
Readme
minimal-request
A minimal opinionated dependency-free request client for node.js.
- It supports just GET and POST
- It asks for gzip by default
- When response status is not 200, it returns an error with the status code + the response.
- Default timeout is 5 seconds. When request timesout, error is 'timeout'
var request = require('minimal-request');
request({
url: 'https://hello.com/blabla',
method: 'post',
body: { hi: 'hello' },
json: true,
headers: { 'accept-language': 'en-GB' },
timeout: 5 // seconds
}, function(err, res, details){
console.log(err);
// -> something like 404 or null
console.log(res);
// -> Something like {hi: 1234}
console.log(details);
// -> Something like { statusCode: 200, headers: { ... }}
});
License
MIT