title: Javascript: SyntaxError: await is only valid in async function
body: <p>I am on Node 8 with <a href="http://docs.sequelizejs.com/" rel="noreferrer">Sequelize.js</a> </p>
  
  <p>Gtting the following error when trying to use <code>await</code>.</p>
  
  <p><code>SyntaxError: await is only valid in async function</code> </p>
  
  <p>Code:</p>
  
  <pre><code>async function addEvent(req, callback) {
      var db = req.app.get('db');
      var event = req.body.event
  
      db.App.findOne({
          where: {
              owner_id: req.user_id,
          }
      }).then((app) =&gt; {
  
                  let promise = new Promise((resolve, reject) =&gt; {
                      setTimeout(() =&gt; resolve("done!"), 6000)
  
                  })
  
                 // I get an error at this point 
                 let result = await promise;
  
                 // let result = await promise;
                 //              ^^^^^
                 // SyntaxError: await is only valid in async function
              }
      })
  }
  </code></pre>
  
  <p>Getting the following error:</p>
  
  <pre><code>               let result = await promise;
                              ^^^^^
                 SyntaxError: await is only valid in async function
  </code></pre>
  
  <p>What am I doing wrong?</p>