It may be that my question title is off, in case the promise.all
is not what I need to solve this issue.
I have a then()
- chain in my promise and I have a series of similar operations that I really should handle differently, but I am new to promises.
return new Promise(function(resolve, reject) {
c.scraper.load().then(function () {
....
var personUrl = url + "/" + c.people[0];
return c.checkPerson(personUrl);
}).then(function(){
var personUrl = url + "/" + c.people[1];
return c.checkPerson(personUrl);
}).then(function(){
var personUrl = url + "/" + c.people[2];
return c.checkPerson(personUrl);
....
I think you get the problem.
The first step would be to combine these three into one, and the second step, if possible, would be to make it work with an unknown number of people in the array c.people
.