Nodejs MongoDB Connection Increase Timeout
Install Mongoose npm package
const mongoose = require('mongoose');
const connectDB = async () => {
mongoose
.connect('mongodb://localhost:27017/mongo_database', {
useCreateIndex: true,
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
serverSelectionTimeoutMS: 1*5000
})
.then(() => console.log('Connected Successfully'))
.catch((err) => console.error('Not Connected'));
}
module.exports = connectDB;