title: async function returns Promise { <pending> }?
body: <p>I have the following async function:</p>
  
  <pre><code>async function readFile () {
    let content = await new Promise((resolve, reject) =&gt; {
      fs.readFile('./file.txt', function (err, content) {
        if (err) {
          return reject(err)
        }
        resolve(content)
      })
    })
  
    console.log(content)
  }
  
  readFile()
  </code></pre>
  
  <p>This runs just fine. It outputs the file buffer to the console as expected. But now, if I try to instead return the value:</p>
  
  <pre><code>async function readFile () {
    let content = await new Promise((resolve, reject) =&gt; {
      fs.readFile('./file.txt', function (err, content) {
        if (err) {
          return reject(err)
        }
        resolve(content)
      })
    })
  
    return content
  }
  
  console.log(readFile())
  </code></pre>
  
  <p>I now get:</p>
  
  <pre><code>Promise { &lt;pending&gt; }
  </code></pre>
  
  <p>Why is this? Why can you use a value inside that function but when you return it out of the function it's now a Promise?</p>
  
  <p>How do you actually make use of this in a normal workflow? For example, lets say I wanted to check if a file exists, then read in the file, then update some database with the content, the synchronous pseudo code would look something like this:</p>
  
  <pre><code>if (fileExists(path)) {
    buffer = readFile(path)
    updateDatabase(buffer)
  }
  </code></pre>
  
  <p>That workflow consists of 3 individual async operations. How would you do something like this with <code>async/await</code>? Is the key that you have to have your entire script wrapped in an <code>async</code> function?</p>
  
  <pre><code>async function doSomething () {
    if (fileExists(path)) {
      buffer = readFile(path)
      updateDatabase(buffer)
    }
  }
  </code></pre>
  
  <p>(Keep in mind that is just pseudo-code but hopefully its gets my point across).</p>