title: Node.JS - Promise to Async/Await example
body: <p>I currently have a project which makes use of native Promises. I am looking to migrate these Promises over to Async/Await. I am having troubles migrating them over; I am trying to follow <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function" rel="nofollow noreferrer">this</a> article. Below is the current code with the Promises which need changing to Async/Await.</p>
  
  <p><strong>routes.js</strong></p>
  
  <pre><code>// Importing user information
  import user from '../server-controllers/user';
  
  // User Information Route
  router.get('/about', (req, res) =&gt; {
    user.profile().then((data) =&gt; {
      return res.render('user', {
        title: data,
      });
    }).catch((e) =&gt; {
      res.status(500, {
        error: e,
      });
    });
  });
  </code></pre>
  
  <p><strong>user.js</strong></p>
  
  <pre><code>/*
  This file contains any server side modules needed.
  */
  
  module.exports = {
  // Returns information about a user
    profile: () =&gt; {
      return new Promise((resolve, reject) =&gt; {
        const user = "John Doe";
        resolve(user);
      });
    },
  };
  </code></pre>
  
  <p>If there is any help in what I would need to do to convert these that would be helpful. I don't know if the code needs changing on either the <code>routes</code> or <code>user</code> file (or both). </p>
  
  <p>The error which I am getting in my terminal is <code>[object Error] { ... }</code></p>