-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContextBrokerWebClient.js
37 lines (31 loc) · 1.15 KB
/
ContextBrokerWebClient.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
34
35
36
37
var cb_xhr = null; // http request
var BACKEND_ADDRESS_CB = "http://orion.lab.fi-ware.org:1026/ngsi10/contextEntities/";
function getCBInfo() {
console.log("Doing search from " + BACKEND_ADDRESS_CB);
restQueryURL = BACKEND_ADDRESS_CB + "urn:smartsantander:testbed:357"
console.log("restQueryURL: " + restQueryURL);
cb_xhr = new XMLHttpRequest();
cb_xhr.onreadystatechange = function() {
if (cb_xhr.readyState === 4) {
if (cb_xhr.status === 200) {
console.log("success: " + cb_xhr.responseText);
var json = JSON.parse(cb_xhr.responseText);
parseCBData(json);
console.log(json);
} else if (cb_xhr.status === 404) {
console.log("failed: " + cb_xhr.responseText);
}
}
}
cb_xhr.onerror = function(e) {
console.log("failed to get CB info.");
};
cb_xhr.open("GET", restQueryURL, true);
cb_xhr.setRequestHeader("Content-Type", "application/json");
cb_xhr.setRequestHeader("Accept", "application/json");
cb_xhr.setRequestHeader("X-Auth-Token", "4wUdbVliV55X5zI68DfDZgVI-by2MBR0s3QhJF7WwwOU0u5AO3f85ycMouzxr3UWGfbCjO3ODcaM6ybtHLcJPA");
cb_xhr.send();
}
function parseCBData(json) {
}
getCBInfo();