title: Unhandled Rejection (TypeError): Cannot read property 'replace' of undefined
body: <p>I am using MongoDB as my database for my Reactjs project. Here, when I am trying to connect the database, it gives me this error - &quot;Unhandled Rejection (TypeError): Cannot read property 'replace' of undefined&quot; <br>
  Here's the code of App.js</p>
  <pre><code> import React from &quot;react&quot;;
  import Sidebar from &quot;./Sidebar&quot;;
  import Feed from &quot;./Feed&quot;;
  import Widgets from &quot;./Widgets&quot;;
  import &quot;./App.css&quot;;
  import { MongoClient } from &quot;mongodb&quot;;
  
  function App() {
    // Connection URI
    const uri =
      &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;;
    // Create a new MongoClient
    const client = new MongoClient(uri);
    async function run() {
      try {
        // Connect the client to the server
        await client.connect();
        // Establish and verify connection
        await client.db(&quot;posts&quot;).command({ ping: 1 });
        console.log(&quot;Connected successfully to server&quot;);
      } finally {
        // Ensures that the client will close when you finish/error
        await client.close();
      }
    }
    run();
  
    return (
      &lt;div className=&quot;app&quot;&gt;
        &lt;Sidebar /&gt;
        &lt;Feed /&gt;
        &lt;Widgets /&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>Any help is greatly appreciated !</p>