batch-call
v0.1.2
Published
Batch Call Wrapper
Downloads
3
Readme
Batch Call Wrapper
This uses request inside and allows to wrap several calls into one batch.
Server-side example:
require('express').all('/batch', require('batch-call')).listen(3000);
Client-side call:
var request = require('request');
var payload = {
users: {
url: 'http://example.com/users/1',
},
project2: {
url: 'http://example.com/projects/2',
method: 'POST',
headers: {
Authentication: 'auth'
},
json: { name: "project2" }
},
simple: 'http://example.com/simle/get'
}
request({ url: 'http://0.0.0.0:3000/batch', json: payload }, function (err, res, body) {
console.log(body);
};
Result of the call:
{
users: {
body: [ 'user1', 'user2' ],
headers: {}
},
project2: {
body: { id: 2, name: 'project2' }
headers: {}
},
simple: {
body: 'result',
headers: {}
}
}