554 viewsNext Amazona

Hi Bassir !
Will we connect our next app with mongoDB through this simple code

[apcode language=”jscript”]

const ConnectDB = async () => {
  try {
    const conn = await mongoose.connect(process.env.MONGODB_URI);
    console.log(`Connected: ${conn.connection.host}`.cyan.underline);
  } catch (error) {
    console.log(`Error: ${error.message}`.red.bold.underline);
    process.exit(1);
  }
};

[/apcode]

it works fine

Bassir Answered question March 9, 2023

Yes, I’m here is the full version of connect function

https://github.com/basir/next-tailwind-amazona/blob/main/utils/db.js#L5

Bassir Answered question March 9, 2023
You are viewing 1 out of 1 answers, click here to view all answers.