I want to store blocks of a json file into an array. Here is my current code, in controller (ctrl) :
var ctrl = this;
var id = (location.href).replace(/.*\//g, ''); //use m.route() ?
ctrl.list = [];
m.request({method: "GET", url: "/data/"+id}).then(function(blocks){
blocks.map(function(block) {
ctrl.list.push(block);
});
});
console.log(ctrl.list); //Result : an empty array. Why ?