LLaza
LLaza

Reputation: 379

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

I'm using MEAN stack and every time I save an user i get this warning

(node:2157) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html

this is where I save user data

user.save(function(err, user) {
    if (err) return res.status(500).send({message: There was an error creating user. Please try again later: ${err}})
    return res
      .status(200)
      .send({ message: 'user successfully created' });
  });

what should I do to delete warning in console?

Upvotes: 2

Views: 392

Answers (1)

Ivan Vasiljevic
Ivan Vasiljevic

Reputation: 5718

You should look this answer.

You need to plugin a promise library (q, bluebird, the es6 one...)

For bluebird:

mongoose.Promise = require('bluebird');

For es6:

mongoose.Promise = global.Promise;

More information you can find in docs.

Upvotes: 1

Related Questions