Created
April 27, 2023 17:07
-
-
Save obiltschnig/c73ebfe1116143164a6df0af5931085a to your computer and use it in GitHub Desktop.
macchina.io REMOTE API JavaScript Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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