174
rated 0 times
[
181]
[
7]
/ answers: 1 / hits: 44308
/ 7 Years ago, thu, december 28, 2017, 12:00:00
let currentProduct;
for (let i = 0; i < products.length; i++) {
currentProduct = products[i];
subscription.getAll(products[i]._id)
.then((subs) => {
update(subs, currentProduct);
});
}
I'm using bluebird, the methods getAll and update return promises. How can I say Wait until the two promises return, then update the currentProduct value? I'm quite new to JS...
More From » node.js