-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 728 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 728 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
27
28
'use strict';
const jayson = require('jayson');
const server = new jayson.server({
add: function(args, callback) {
callback(null, args[0] + args[1]);
}
});
const client = new jayson.client(server);
const 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
});