You are developing an e-commerce application where multiple API calls are made to fetch product details. How can you efficiently handle multiple Promises to ensure that even if one fails, others continue execution?

  • Promise.allSettled()
  • Promise.race()
  • Promise.all()
  • Promise.any()
In this scenario, you can efficiently handle multiple Promises using Promise.allSettled(). This method returns an array of results for all Promises, allowing you to handle both resolved and rejected Promises without stopping the execution of others. Promise.race() would stop execution on the first rejection, Promise.all() requires all to resolve, and Promise.any() stops on the first resolution.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *