Thursday, 1 June 2023

How to solve : MongooseError: Mongoose.prototype.connect() no longer accepts a callback

 Today i will share again about "How to solve : MongooseError: Mongoose.prototype.connect() no longer accepts a callback" ok lets check it out the following code :

This is code made script error :

mongoose.connect('mongodb://surac:an1.@127.0.0.1:27017/?authMechanism=DEFAULT', {
    useNewUrlParser: true,
}, err => err ? console.log(err) :
    console.log('Connected to yourDB-name database'));

Try to change scripts like below


mongoose.connect("mongodb://surac:an1.@127.0.0.1:27017/?authMechanism=DEFAULT'", {
  useNewUrlParser: true
},).then(()=> console.log('Connected Sucessfully')).catch((err) => {console.error(err);});

And now Connected Successfully.

Thanks for your visited

No comments:

Post a Comment