I have a problem with waiting for my forEach loop, which has a promise inside, to finish. I can't find any real solution, that would make the script wait till the end, before continuing with the execution. I cannot make the someFunction synchronous.
makeTree: function (arr) {
arr.forEach(function (resource) {
someModule.someFunction(resource).then(function () { //a Promise
//do something with the resource that has been modified with someFunction
});
});
// do something after the loop finishes
}