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

2
  • Did you check this:: stackoverflow.com/questions/38138445/… Commented Feb 7, 2018 at 10:04
  • I guess, it's a warning, and before execution connectToDb function, mongoose.Promise is mpromise . Commented Feb 7, 2018 at 10:07

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.