I want to query my OH2 influx db instance from a static webpage for displaying data on a map. I can’t seem to get data from the database into the script. When I hit the url in my browser I get JSON results, however I was prompted for authentication so I thought perhaps I should use http://username:password@ip:port in my script? Can anyone confirm?
However when my script on the webpage executes, I am not getting any results with or without credentials in the url. I just get “Error” logged to the console. Can anyone point me toward how to debug what is happening or give me suggestions to resolve?
My javascript:
var url="http://localhost:8086/query?db=openhab_db&epoch=ms&q=SELECT+*+FROM+%22mqttBeccaLatLon%22";
console.log(url);
$.ajax({
url: url,
type: 'GET',
success: function(data) { //we got the response
console.log(data);
},
error: function(test, status, exception) {
console.log("Error: " + exception);
}
})