I am attempting to establish a connection to Mongodb using the Thunder client extension in Vs code.
Here is the code snippet I have implemented so far, but unfortunately, I am encountering an error that causes the application to crash.
const mongoose = require('mongoose');
const mongoURI = "mongodb+srv://****:****@cluster0.jswzjap.mongodb.net"
const connectToMongo = ()=>{
mongoose.connect(mongoURI, ()=>{
console.log("Connected to Mongo Successfully");
})
}
module.exports = connectToMongo;
The above snippet represents the connection string for MongoDB.
D:\I NOTE2\inote3\backend>nodemon ./index.js
[nodemon] 3.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node ./index.js`
Example app listening on port http://localhost:3000
{ name: 'xyz', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b5d0d8d4dcd9f5d2d8d4dcd99bd6dad8">[email protected]</a>', password: '4567' }
D:\I NOTE2\inote3\backend\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:186
const err = new MongooseError(message);
^
MongooseError: Operation `users.insertOne()` buffering timed out after 10000ms
at Timeout.<anonymous> (D:\I NOTE2\inote3\backend\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:186:23)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
Node.js v18.17.1
[nodemon] app crashed - waiting for file changes before starting...
This pertains to the specific error message that I am currently facing.