title: How do I read a file in an async function without promises?
body: <p>I'm trying to read/write to a file in an async function (example):</p>
  
  <pre><code>async readWrite() {
        // Create a variable representing the path to a .txt
        const file = 'file.txt';
  
        // Write "test" to the file
        fs.writeFileAsync(file, 'test');
        // Log the contents to console
        console.log(fs.readFileAsync(file));
  }
  </code></pre>
  
  <p>But whenever I run it I always get the error:</p>
  
  <pre><code>(node:13480) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'map' of null
  </code></pre>
  
  <p>I tried using bluebird by installing it using <code>npm install bluebird</code> in my project directory and adding:</p>
  
  <pre><code>const Bluebird = require('bluebird');
  const fs = Bluebird.promisifyAll(require('fs'));
  </code></pre>
  
  <p>to my <code>index.js</code> (main) file, as well as adding:</p>
  
  <pre><code>const fs = require('fs');
  </code></pre>
  
  <p>to every file where I wan't to use fs.</p>
  
  <p>I still get the same error and can only narrow down the problem to fs through commenting out stuff.</p>
  
  <p>Any help would be appreciated.</p>