I am facing an issue in JavaScript. I want to do change promise.all
into single promise request.
What should I do? Anyone help me?
It just a sample code for understand:
count: (4) [Promise, Promise, Promise, Promise]
data: (4) [{…}, {…}, {…}, {…}]
//send delivery report with send sms response
Promise.all(count).then(function(data) {
var delivery_reports = [];
console.log(data);
SendDeliveryReport(data);
})
.catch(function(error) {
console.log(error);
})
// execute promises sequentially, passing the parameters from an array
count.reduce(
(p, x) =>
p.then(_ => myPromise(x)),
//send delivery report with send sms response
Promise.all(count).then(function (data){
var delivery_reports = [];
console.log(data);
SendDeliveryReport(data);
})
.catch(function (error){
console.log(error);
})
)