This is my first shot at nested promises. I'm using the bluebird library but I think the idea is the same for all of the promise libraries.
At a high level, this is what I'm trying to do:
myService.getSomeData(url)
.then((data) => {
myOtherService.getMoreData(data.uniqueId)
.then((thisDataIsAnArray) => {
//loop over the data above and do something
});
});
getMoreData()
is supposed to make X service calls and store the results in an array X elements long. This is where I start getting lost, in that I'm not sure how to craft this method and what I should be returning from it. I've taken a few stabs at bluebird's Promise.all
and Promise.map
but am floundering and thought I'd solicit suggestions.