Mongoose default connection is disconnected
Mongoose default connection has occured MongoNetworkError: connection 0 to cluster0-shard-00-01-utzss.mongodb.net:27017 closed error
(node:8421) UnhandledPromiseRejectionWarning: MongoNetworkError: connection 0 to cluster0-shard-00-01-utzss.mongodb.net:27017 closed
at TLSSocket.<anonymous> (/media/tyro/6250439650437039/Work Space/Web/JS-Learning/node-restfulApi-shop/node_modules/mongodb/lib/core/conn
ection/connection.js:352:9)
。
const dbURL = 'mongodb+srv://node-rest-shop:node-rest-shop@cluster0-utzss.mongodb.net/test?retryWrites=true&w=majority';
mongoose.connect(dbURL,{ useUnifiedTopology: true, useNewUrlParser: true });
mongoose.connection.on('connected', function(){
console.log("Mongoose default connection is open to ", dbURL);
});
mongoose.connection.on('error', function(err){
console.log("Mongoose default connection has occured "+err+" error");
});
mongoose.connection.on('disconnected', function(){
console.log("Mongoose default connection is disconnected");
});