I have method that resolves a promise that retrieves some Products
global.getProducts().then(function (prodPromised) {
For each prodPromised I have a Category ID but I also want the Category Name. So, I create an array of promises in which I assing the Category Name to each Product.
var products = [];
for (var i = 0; i < prodPromised.length; i++) {
promises.push(self.createCatName(prodPromised[i]));
}
After that I resolve the promises ...
Promise.all(promises).then((products) => {
... I loop them for some operations
for (var i = 0; i < products.length; i++) {
The problem is that I'd like to store the array products in a "upper" position so to use it for another method.
I suppose there's something related to the hoisting, but I dont' understand how to do it :-(
Thanks