title: Javascript await promise in foreach
body: <p>Hello im trying to loop throught an array with the</p>
  <p>I tried to make the forEach loop Async</p>
  <pre><code>content.forEach(asnyc(element) =&gt; {
     console.log(func(element)
  })
  </code></pre>
  <p>This gave me a syntax error stating that it expects a ,
  forEach statement like this</p>
  <pre><code>content.forEach(element =&gt; {
     console.log(func(element)
  })
  </code></pre>
  <p>The func will return a promise and currently I need to find a way to await it</p>
  <p>the function this code is running in is Async
  And im perfectly able to await a promise in it
  However in a forEach loop it doesnt seem to work</p>
  <p>I tried to do the following</p>
  <pre><code>content.forEach(element =&gt; {
     console.log(await func(element)
  })
  </code></pre>
  <p>SyntaxError: await is only valid in async functions and the top level bodies of modules</p>
  <p>I tried to make the forEach loop Async</p>
  <pre><code>content.forEach(asnyc(element) =&gt; {
     console.log(func(element)
  })
  </code></pre>
  <p>This gave me a syntax error stating that it expects a ,</p>