-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
32 lines (27 loc) · 930 Bytes
/
example.js
File metadata and controls
32 lines (27 loc) · 930 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
29
30
31
32
/*
* Copyright (C) 2023 Radix IoT LLC. All rights reserved.
*/
// change to require('@radixiot/mango-client') when installed via NPM
const MangoClient = require('./src/mangoClient');
const client = new MangoClient({
protocol: 'https',
host: 'localhost',
port: 8443,
rejectUnauthorized: false
});
const DataPoint = client.DataPoint;
const User = client.User;
User.login('admin', 'admin').then(data => {
console.log(`Logged in as '${data.username}'.`);
return DataPoint.getValue('internal_mango_num_data_points');
}).then(data => {
console.log(`There are ${data.value} data points.`);
// you can perform any arbitrary rest request like this
return client.restRequest({
path: '/rest/v3/data-points/internal_mango_num_data_points',
method: 'GET',
//data: {object}
});
}).then(response => {
console.log(`The data point's name is '${response.data.name}'`);
});