so I have a promise that collects data from the server, but only collects 50 responses at a time. I have 250 answers to collect.
I could just flesh out promises together as shown below
new Promise((resolve, reject) => {
resolve(getResults.get())
})
.then((results) => {
totalResults.concat(results)
return getResults.get()
})
.then((results) => {
totalResults.concat(results)
return getResults.get()
}).then((results) => {
totalResults.concat(results)
return getResults.get()
})
In this case, I need only 250 results, so this seems like a manageable solution, but there is a way to link promises in a loop. so I run the loop 5 times and fulfill the following promise every time.
Sorry, I'm new to promises, and if these were callbacks, this is what I would do.
source
share