title: TypeError: connection.once(...).catch is not a function
body: <pre><code>require('dotenv').config();
  const mongoose = require('mongoose');
  function connectDB() {
      // Database connection 
      mongoose.connect(process.env.MONGO_CONNECTION_URL, 
      { useNewUrlParser: true, useCreateIndex:true, useUnifiedTopology: true, useFindAndModify : true });
      const connection = mongoose.connection;
      connection.once('open', () =&gt; {
          console.log('Database connected ');
      }).catch(err =&gt; {
          console.log('Connection failed ');
      });`
  </code></pre>
  <p>}
  everytime i am getting the error that catch is not a function at connectDB error:</p>
  <pre><code>C:\Users\user\Desktop\mern\config\db.js:15
      }).catch(err =&gt; {
              ^
  
  TypeError: connection.once(...).catch is not a function
      at connectDB (C:\Users\user\Desktop\mern\config\db.js:15:13)
  </code></pre>