Using filesystem in node.js with async / await : <p>I would like to use async/await with some filesystem operations. Normally async/await works fine because I use <code>babel-plugin-syntax-async-functions</code>.</p>

<p>But with this code I run into the if case where <code>names</code> is undefined:</p>

<pre><code>import fs from 'fs';

async function myF() {
  let names;
  try {
    names = await fs.readdir('path/to/dir');
  } catch (e) {
    console.log('e', e);
  }
  if (names === undefined) {
    console.log('undefined');
  } else {
    console.log('First Name', names[0]);
  }
}

myF();
</code></pre>

<p>When I rebuild the code into the callback hell version everything is OK and I get the filenames.
Thanks for your hints.</p>
