I initialized an array and got the data through a function call that returns a promise. In the then
I populated the array and printing the array works fine. Outside of the promise I try to access the array and it's back to being empty. How can I keep the changes made in the then
function?
var arr : IHash = {};
this.getTags(parameters)
.then((data) => {
for (var t in data.Tags) {
arr[t] = data.Tags[t];
this.$log.debug(arr["firstindex"]); //outputs data
}
}, (err) => {
this.$log.debug(err);
});
this.$log.debug(arr["firstindex"]); //prints nothing