-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathclient.js
37 lines (30 loc) · 965 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
35
36
37
'use strict';
const jayson = require('jayson');
const client = new jayson.client.http({
port: 3000
});
// invoke "sum" with array
client.request('sum', [3, 5, 9, 11], function(err, response) {
if(err) throw err;
console.log(response.result); // 28
});
// invoke "sum" with an object
client.request('sum', {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
});
// invoke "context"
client.request('context', {hello: 'world'}, function(err, response) {
if(err) throw err;
console.log(response.result); // {} - just an empty object
});