I want to get some data from this page http://orbit5.ds.cs.umu.se:8888/vrio/debug/blk. the data on this page updates every time you refresh the page. So I would like to have these updated values. In order to update the values I could use $timeout but then I need to somehow get these values outside of getdata because I want to then plug these values into another function for making a chart otherwise the whole chart will keep on rendering every time the function updates. and I cannot get the values outside of the function I found this answer on stackoverflow but most of the answers as far as I understand use data from inside the function.
How can I get the updated values outside of the JavaScript function and plug them into another function? Or maybe there is another better approach to solve this problem?
my code:
function getData(){
var data;
$http.get(path).then(function(response){
data = response.data
console.log(response.data) //works fine
})
return data
}
console.log(data)//returns undefined
Now If I want to update the function with $timeout
I would need to do something like this
$timeout(getData, 3000)
now how can I get to these updated values?
Edit:
var myData = setInterval( function(){
$http.get(path).then(function(response){
return response.data['Block Devices']
})
}, 1000 );
console.log(myData)
});
returns 14 I dont know what that is but certainly not right data