Hello,
I want to develop a beacons web manager for my own beacons. I found the Cloud API here, https://cloud.estimote.com/docs/#api-Devices-GetDevice
I tried with AJAX, but got the error :
XMLHttpRequest cannot load https://cloud.estimote.com/v2/devices/. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘https://***’ is therefore not allowed access.
This is the function I used:
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var beacons = JSON.parse(this.responseText);
var txt = “”;
var x;
for (x=0; x < beacons.length; x++) {
console.log(beacons[x].shadow.id + “_” + beacons[x].shadow.name);
}
}
};
var myUrl=“https://cloud.estimote.com/v2/devices/”;
xhttp.open(“GET”, myUrl, true);
xhttp.setRequestHeader(“Access-Control-Allow-Origin”, “*”);
xhttp.setRequestHeader(“Authorization”, “Basic” + btoa(“AppID:AppToken”));
// xhttp.setRequestHeader(“Accept”, “application/json”);
xhttp.setRequestHeader(“Accept”,“application/json; charset=utf-8”);
xhttp.send();
}
Does anyone have any idea on this? Thank you