-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgps_data.js
46 lines (41 loc) · 1.04 KB
/
gps_data.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
38
39
40
41
42
43
44
45
46
module.exports = {
get_gps_data: function(callback) {
var oauth = require('./oauth.js');
var https = require('https');
var nbi_label = "nbi";
var nbi_host = process.env[nbi_label+"_IP_ADDRESS"];
var nbi_port = process.env[nbi_label+"_TCP_9999_PORT"];
oauth.get_oauth(function(oauth_token) {
console.log('oauth in getdata:');
console.log(oauth_token);
var header = {
"Authorization": "Bearer "+oauth_token
};
var options = {
host: nbi_host,
port: nbi_port,
path: '/api/v1/mw/gps/location',
method: 'GET',
rejectUnauthorized: false,
header
};
var req = https.request(options, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
console.log('response: ');
data = JSON.parse(d);
console.log(data);
});
res.on('end', () => {
console.log('No more data in getdata-api response.');
callback(data);
});
});
req.on('error', (e) => {
console.error(e);
});
req.end();
});
}
}