1.0.1 • Published 7 years ago
min-req-promise v1.0.1
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)
urlThe full url to requestoptionsan http.request options object. Can be extended with abodyattribute.
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);
});