-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode-me.js
33 lines (28 loc) · 888 Bytes
/
node-me.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
// The API Endpoint to access.
const endpoint = '/me';
// Required modules.
const fs = require('fs');
const http = require('https');
// Read the API token.
const token = fs.readFileSync('./api-token.txt', 'utf8').trim();
// Set the HTTP options.
var options = {
hostname: 'api.exonet.nl',
path: '/' + endpoint.replace(/^\/+/g, ''),
method: 'GET',
headers: {
'Authorization': 'Bearer ' + token,
'Accept': 'application/vnd.Exonet.v1+json'
}
};
// Make the request.
http.request(options, function (res) {
res.on('data', function (chunk) {
const decodedResponse = JSON.parse(chunk);
console.log();
console.log('Hello ' + decodedResponse.data.attributes.name);
console.log();
console.log('-'.repeat(10) + '[ Full decoded response ]' + '-'.repeat(10));
console.log(decodedResponse);
});
}).end();