Skip to content

Instantly share code, notes, and snippets.

@obiltschnig
Created April 27, 2023 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obiltschnig/c73ebfe1116143164a6df0af5931085a to your computer and use it in GitHub Desktop.
Save obiltschnig/c73ebfe1116143164a6df0af5931085a to your computer and use it in GitHub Desktop.
macchina.io REMOTE API JavaScript Example
const https = require('https');
const token = '<jwt>';
const requestOptions = {
hostname: 'remote.macchina.io',
port: 443,
path: '/my-devices/api/devices?status=all',
method: 'GET',
headers: {
'Authorization': 'Bearer ' + token
}
};
var json = '';
const req = https.request(requestOptions, res => {
console.log('Response: ' + res.statusMessage);
res.on('data', data => {
json += data;
});
res.on('end', data => {
//const devices = JSON.parse(json);
console.log('Devices: ' + json);
});
});
req.on('error', error => {
console.error(error);
});
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment