Skip to content
Snippets Groups Projects

Resolve "Configure MongoDB Connection"

1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
+ 1
1
@@ -4,7 +4,7 @@ const mongoose = require('mongoose');
@@ -4,7 +4,7 @@ const mongoose = require('mongoose');
async function connectDB() {
async function connectDB() {
try {
try {
// Connect using the MongoDB URI from environment variables
// Connect using the MongoDB URI from environment variables
const conn = await mongoose.connect("mongodb://127.0.0.1:27017");
const conn = await mongoose.connect(process.env.MONGO_URI || "mongodb://127.0.0.1:27017/todo_app");
console.log(`MongoDB connected: ${conn.connection.host}`);
console.log(`MongoDB connected: ${conn.connection.host}`);
// Get the database object from the connection
// Get the database object from the connection
Loading