0

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); }) ) 
17
  • 2
    What is count? SendDeliveryReport? Commented Sep 4, 2020 at 11:58
  • you can check a add count result @ Commented Sep 4, 2020 at 12:01
  • 1
    It's pretty unclear what you're asking still. What's the problem with this current code? What does or doesn't work as expected? What do you want to change? Commented Sep 4, 2020 at 12:02
  • i want to change promise.all into new promise request @ Commented Sep 4, 2020 at 12:03
  • 1
    How do you expect to change 4 requests into one without Promise.all? BTW you should be use @username to reply to someone, not a link to the user's profile. Commented Sep 4, 2020 at 12:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.