I just started using Promise
in my node app. And I believe that in the code below the loop will break if one of then returns an error, which is rejected.
Is there a way to let the loop finish, skipping the ones with errors. And I still would like all the error notices at the end of the loop.
One more question: Is there a better way to resolve
instead of using count++; if(count===items.length) resolve(items)
get_customer_purchase = (items) => {
return new Promise((resolve, reject)=>{
let count = 0;
for (let i in items) {
get_options(items[i].id).then((options)=>{
//do some process
count++; if(count===items.length) resolve (items)
}).catch((error)=>reject(error))
}
})
}