Skip to content
Snippets Groups Projects
Commit a7c2c85c authored by Rokas Stankunas's avatar Rokas Stankunas
Browse files

Changed DB connection to be taken from .env file; specified DB name

parent b814678f
1 merge request!4Resolve "Configure MongoDB Connection"
......@@ -4,7 +4,7 @@ const mongoose = require('mongoose');
async function connectDB() {
try {
// 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}`);
// Get the database object from the connection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment