-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.js
25 lines (22 loc) · 783 Bytes
/
demo.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
//
// To try this demo, just change the email and password below
// to match your sensorpush credentials
//
const sensorpush = require('sensorpush').api
const email = '[email protected]'
const password = 'BO000yAH!'
async function main() {
try {
// autorize ourselves
const {authorization} = await sensorpush.oauth.authorize(email, password)
const {accesstoken} = await sensorpush.oauth.accesstoken(authorization)
// get and print some data
const sensors = await sensorpush.devices.sensors(accesstoken)
const gateways = await sensorpush.devices.gateways(accesstoken)
const samples = await sensorpush.samples(accesstoken, new Date(Date.now() - 3600000), 5)
console.log({sensors, gateways, samples})
} catch (err) {
console.error(err)
}
}
main()