I'm working with some old code and I'm trying to return results for two arrays of promises.
So basically body contains first and second which are arrays of ids. I know that the below code works for a small array of of 1 to 5 ids, but if I were to do a few hundred, would the resolve fire before I get the hundred of results from both promise arrays?
 const doSomething = (body) => {
    return new Promise((resolve, reject) => {
      const promisesOne = body.first.map((id) => 
        doSomethingOne(id)
      );
      const promisesTwo = body.second.map((id) => 
        doSomethingTwo(id)
      );
      let response = {
        first: {}
        second: {}
        headers: 'mock headers'
      };
      Promise.all(promisesOne).then((results) => {
        response.first = results;
      });
      Promise.all(promisesTwo).then((results) => {
        response.second = results;
      });
      resolve(response);
  });
};
Also I won't be able to refactor this to async/await as this codebase does not use it.
 
     
    