title: MongoNotConnectedError: MongoClient must be connected to perform this operation. How to handle this error?
body: <p><a href="https://i.stack.imgur.com/SYkUo.png" rel="nofollow noreferrer">cmd</a>    <strong>How can i solve this. Just showing  MongoClient must be connected to perform this operation
  at getTopology ..... at collection.insertOne .... at maybePromise..</strong></p>
  <pre><code>const express = require('express');
  const {MongoClient} = require('mongodb');
  const password = 'NLJXkuGFhUd68@9';
  
  
  
  const uri = &quot;mongodb+srv://organicUser:NLJXkuGFhUd68@9@cluster0.px7rc.mongodb.net/organicdb? 
  </code></pre>
  <p>retryWrites=true&amp;w=majority&quot;;
  const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });</p>
  <pre><code>const app = express();
  
  app.get('/', (req, res) =&gt; {
      res.send(&quot;Hello, I am Working&quot;);
  })
  
  
  
  client.connect(err =&gt; {
    const collection = client.db(&quot;organicdb&quot;).collection(&quot;products&quot;);
  
    // perform actions on the collection object
    const product = {name: &quot;Modhu&quot;, price: 120, quantity: 30};
    collection.insertOne(product)
    .then(result =&gt; {
        console.log(&quot;One product added&quot;);
    })
    console.log(&quot;database connected&quot;);
  
  });
  
  
  app.listen(8000)
  </code></pre>