title: My Async won't stop for my Await - What does AWAIT wait for then?
body: <p>I am getting into Node, and being thrown into the world of async programming.</p>
  
  <p>I thoroughly read this article on Mozilla's site (along with many other links teaching about the async and await keywords): </p>
  
  <p><strong><a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await</a></strong></p>
  
  <p>I have a project I am starting that will require numerous database calls, one after another. Some queries will rely upon the previous one's results. That being said, I decided I better practice and write some testing code.</p>
  
  <p>Here is my testing code:</p>
  
  <pre><code>var users, items;
  
  const getData = async function(){
      // This is a DB call. Will take
      // a little bit of time to complete.
  
      setTimeout(() =&gt; {
          var queryResults = "A list of items";
          items = queryResults;
      }, 1000);
  
      return items;
  }
  
  const getUsers = async function(){
      setTimeout(() =&gt; {
          var queryResults = "A list of items";
          users = queryResults;
      }, 1000);
  
      return users;
  }
  
  const init = async function(){
      var itemSuccess = await getData();
      var userSuccess = await getUsers();
  
      console.log(`Here is your items: ${items}, and here are your users: ${users}`);
  }
  
  init();
  </code></pre>
  
  <p>My code failed with:</p>
  
  <pre><code>Here is your items: undefined, and here are your users: undefined
  </code></pre>
  
  <p>So naturally I headed back to Mozilla. I re-read the docs, and tried a few changes. Still, no success. Ultimately I ended up back at my original code above.</p>
  
  <p>I cannot see why this is failing. I am simulating the time a query would take by using a timeout. If async does what it says, both functions should return their value, and then my console log should print out the correct results.</p>
  
  <p>Does anyone see where I am going wrong?</p>
  
  <p>Thank you.</p>