forked from tedeh/jayson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
34 lines (28 loc) · 913 Bytes
/
client.js
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
29
30
31
32
33
34
var jayson = require('./../..');
var client = jayson.client.http({
port: 3000
});
// invoke "sumCollect" with array
client.request('sumCollect', [3, 5, 9, 11], function(err, response) {
if(err) throw err;
console.log(response.result); // 28
});
// invoke "sumCollect" with object
client.request('sumCollect', {a: 2, b: 3, c: 4}, function(err, response) {
if(err) throw err;
console.log(response.result); // 9
});
// invoke "sumDefault" with object missing some defined members
client.request('sumDefault', {b: 10}, function(err, response) {
if(err) throw err;
console.log(response.result); // 12
});
// invoke "isArray" with an Object
client.request('isArray', {a: 5, b: 2, c: 9}, function(err, response) {
if(err) throw err;
console.log(response.result); // true
});
client.request('sum', [1, 2, 3], function(err, response) {
if(err) throw err;
console.log(response.result); // 6
});