title: Promise.all() not waiting for async process
body: <p>In node.js I am trying to loop through some items, complete an async process for each one and then wait for each to be complete before the next one starts. I must be doing something wrong as the Promise.all() is not waiting for any of the async processes to complete! My code is below:</p>
  
  <pre><code>getChildLessons() {
  
   return new Promise((resolve, reject) =&gt; {
  
    Promise.all(
  
      //nested for loop is needed to get all information in object / arrays
     this.lessons.levels.map((item, i) =&gt; {
  
        item.childlevels.map((childItem, iChild) =&gt; {
  
          return ((i, iChild) =&gt; {
  
            //return async process with Promise.resolve();
            return this.horseman
            .open(childItem.url)
            .html()
            .then((html) =&gt; {
              //adding some information to an array
            })
            .then(() =&gt; {
                return Promise.resolve();
            }).catch((err) =&gt; {
              reject(err);
            });
  
          })(i, iChild);
  
        });
    })
  
    // Promise.all().then()
  ).then(() =&gt; {
    resolve(this.lesson);
  })
  .catch((err) =&gt; {
    console.log(err);
  });
  });
  }
  </code></pre>
  
  <p>I am fairly new to async with node.js so please could you provide a clear example if possible.</p>