title: UnhandledPromiseRejectionWarning in Express App
body: <p>I'm currently learning Javascript/Node.js/MEAN stack and I'm following an Express tutorial. </p>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>(node:11524) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'close' of undefined
    (node:11524) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.</p>
  </blockquote>
  
  <p>When I hit this route in my browser. </p>
  
  <pre><code>function router(nav) {
  adminRouter.route('/')
      .get((req, res) =&gt; {
          const url = 'mongodb://localhost:27017';
          const dbName = 'libraryApp';
  
          (async function mongo() {
              let client;
              try {
                  client = await mongoClient.connect(url);
                  debug('Connected correctly to server');
  
                  const db = client.db(dbName);
  
                  const response = await db.collection('books').insertMany(books);
                  res.json(response);
              } catch (err) {
                  debug(err.stack);
              }
              client.close();
          }());
      });
  
  return adminRouter;
  </code></pre>
  
  <p>}</p>
  
  <p>Could someone point out the issue and explain what the issue is please. </p>