forked from tedeh/jayson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (21 loc) · 709 Bytes
/
index.js
File metadata and controls
26 lines (21 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var jayson = require(__dirname + '/../..');
var server = jayson.server({
add: function(args, callback) {
callback(null, args[0] + args[1]);
}
});
var client = jayson.client(server);
var batch = [
client.request('does_not_exist', [10, 5]),
client.request('add', [1, 1]),
client.request('add', [0, 0], null) // a notification
];
client.request(batch, function(err, errors, successes) {
if(err) throw err;
console.log('errors', errors); // array of requests that errored
console.log('successes', successes); // array of requests that succeeded
});
client.request(batch, function(err, responses) {
if(err) throw err;
console.log('responses', responses); // all responses together
});