title: Javascript map array promise.all
body: <p>I am trying to process all images in an array and push all of the processed images in other array.</p>
  <p>The processing stuff runs async, so I am using await Promise.all to wait until all of the images has been processed. Anyways, the array is undefined when the code finishs.</p>
  <p>Here is what I am doing:</p>
  <pre><code>async function processImage(image) {
      // ... stuff
      return new Promise((resolve, reject) =&gt; {
        (async () =&gt; {
          // Validate each image uploaded by the user
          const images = await Promise.all( // &lt;--------------------------------
            imagesIds.map(async (id) =&gt; {
               // ... async stuff
  
              if(!error)
                return processedImage; // &lt;-------------------------------
              else {
                reject(error);
              }  
            }
          }
          // ... stuff
          console.log(images); &lt;-------- undefined
          resolve();
        })();
    }  
  </code></pre>
  <p>Any ideas what I am doing wrong? Thanks.</p>