0

I'm passing the URL into the function to connect to mlab.

This is my function :

function connectToDb(mongoURL) {
    mongoose.Promise = global.Promise;

    mongoose.connect(mongoURL, (err, db) => {
      err ? console.log(err) : console.log('Connected mongoose');
    });
}

I call the function connectToDb in another function :

function getURL(){
 connectToDb(mongoURL);
}

ERROR :

(node:1380) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoo

BlackBeard
  • 10,246
  • 7
  • 52
  • 62
  • Did you check this:: https://stackoverflow.com/questions/38138445/node3341-deprecationwarning-mongoose-mpromise – Sudhir Bastakoti Feb 07 '18 at 10:04
  • I guess, it's a warning, and before execution `connectToDb` function, `mongoose.Promise` is `mpromise` . – Cr. Feb 07 '18 at 10:07

1 Answers1

1

this error should have been solved by the latest updates. if you're using mongoDB 3.6.2 or later, and mongoose 5.0.0. However if you are using an older version of mongoose and don't want to update, you can plug in your own promise library. reference

This warning can also be resolved if you add

mongoose.Promise = global.Promise;

after requiring mongoose but before connecting to db.

Rakan
  • 400
  • 2
  • 12