min-req-promise
v1.0.1
Published
An extra light http client
Downloads
2,760
Readme
Minimal Request Promise
request
and request-promise
are great, but I was looking for an some extra-light implementation.
Usage
client.<get|post|put|delete|head>(url, [options])
url
The full url to requestoptions
an http.request options object. Can be extended with abody
attribute.
response: An http.IncomingMessage
object, complemented with a body
attribute containing the response body data;
const client = require('min-req-promise');
return client.get('https://some/url')
.then(response => {
// response is an http.IncomingMessage
// with an extra `body` member
console.log(response.headers);
console.log(response.body);
});
Posting data
POST
|PUT
,.. body can be injected in options.body
:
const client = require('min-req-promise');
return client.post('http://some/url', {
headers: {
'Content-type': 'application/x-www-form-urlencoded'
},
body: 'foo=bar'
})
.then(response => {
console.log(response);
});