in a Node.JS app, I am trying to make 3 API calls to different endpoints, which are:
/GET ProductInformation : returns the information for the given productID.
/GET ProductRecommendation : returns the product recommendation for the given productID
/GET ProductReview : returns product reviews and rating for the given productID
None of the above call is dependent on the other, therefore, if possible, I am trying to avoid a chain of Promise like :
getProductInfo(productId)
.then(result =>{
getProductRecommendation(productId)
.then(result =>{
getProductReview(result => {
callback('done') // all calls are done, we can return now!
})
})
Is there a better approach for making this sort of async operations ?
The reason that I am looking to see if there is a better way or not, is because in reality I have more than just 3 calls, and doing this makes the code hard to maintain and read.