-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_scenes.js
More file actions
41 lines (30 loc) · 844 Bytes
/
list_scenes.js
File metadata and controls
41 lines (30 loc) · 844 Bytes
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
var request = require('request');
var config = require('./config.json');
/**
* API call to `create` scene
* @params config.user_token - user token which has authenticated oauth2 application
* @params scene_data - new scene payload for making the API request
*/
function list_scenes() {
var options = {
method:"GET",
url:"https://api.artik.cloud/v1.1/scenes",
headers:{
'Authorization': 'Bearer ' + config.user_token,
'Content-Type': 'application/json'
}
};
request(options, function (error, response, body) {
handle_response(error, response, body)
});
}
function handle_response(error, response, body) {
if(error) throw new Error(error);
try {
console.log("\n", JSON.stringify(body));
} catch(e) {
console.log("\n> ", e);
}
}
console.log("Listing your Scenes:");
list_scenes();