Connect Next.js version 13.5.5 with mongoose 7.6.3

122 views Asked by At

I'm working with Next.js version 13.5.5 and Mongoose 7.6.3, and the error I'm encountering is the following: MongooseError: Mongoose.prototype.connect() no longer accepts a callback. This error occurred while generating the page. Any console logs will be displayed in the terminal window.

And the code I have in my connectMongo.js file is as follows:

import mongoose from 'mongoose';

const connectMongo = async () => mongoose.connect(process.env.MONGO_URI,
{useNewUrlParser: true, useUnifiedTopology:true},
()=> {
    console.log('Connected to MongoDB')
})

export default connectMongo;

I hope to receive a response on how to make the requests work in MongoDB

0

There are 0 answers