title: await doesn't wait before moving onto next line of code
body: <p>My code:</p>
  <pre><code>async function main(collection, token, symbol) {
    await collection.deleteMany({});
    const priceHistory = await makePriceHistoryRequest(token, symbol, slow*2);
    await insertPriceHistory(collection,priceHistory);
    const res = await priceQuote(token,symbol);
    await insertQuote(collection,res,symbol);
    return await avgFastSlow(fast,slow,collection);
  }
  </code></pre>
  <p>My code makes request to 2 endpoints and update MongoDB collection. The last code:</p>
  <pre><code>return await avgFastSlow(fast,slow,collection);
  </code></pre>
  <p>takes the updated collection from the two endpoints to calculate fast and slow average. Problem is that it is not waiting before moving onto the this last line of code. Isn't the point of async function to make it &quot;wait?&quot;</p>
  <p>Mystified here. Thanks for the help</p>
  <p>@ihoryam Thanks for responding. Here is <code>insertQuote</code> function:</p>
  <pre><code>function insertQuote(collection,res,symbol) {
    const quote = res[symbol];
    const date1 = new Date(quote.quoteTimeInLong).toLocaleDateString();
    const record = {
      dateInMS: quote.quoteTimeInLong,
      dateFormatted: date1,
      open: quote.openPrice,
      high: quote.highPrice,
      low: quote.lowPrice,
      close: quote.regularMarketLastPrice,
      volume: quote.totalVolume
    }
    console.log(&quot;below is from insertQuote&quot;);
    console.log(record);
    helper(collection,record);
  }
  
  async function helper(collection,record) {
    await collection.insertOne(record);
  }
  </code></pre>
  <p>To further isolate the issue, I added console.log to see if the request is returning updated value, and it is:</p>
  <pre><code>console.log(&quot;below is from insertQuote&quot;);
  console.log(record);
  </code></pre>
  <p>So this tells me the problem is with MongoDB isn't updated in time before the code moves onto the calculation part of the code:</p>
  <pre><code>async function helper(collection,record) {
    await collection.insertOne(record);
  }
  </code></pre>
  <p>Any ideas? Thanks</p>