I am unable to pass requests with postman, and the error message is the one being printed on console. Before applying then method I was able to see the connection successful mssage but still wasn't able to get/post via postman
//database connection
mongoose.connect(
process.env.MONGO_URL,
{ useNewUrlParser: true, useUnifiedTopology: true }).then(()=>{
console.log("connection successful")
}).catch((error)=>{
console.log("Error occured on connection")
});
Requiring the connection via
const mongoose = require("mongoose");
and the MONGO_URL mentioned in .env file is
MONGO_URL = mongodb+srv://username:password@cluster0.8noo9.mongodb.net/dbname?retryWrites=true&w=majority
been stuck here for a while. I am setting up mongoose for the first time
It was due to not whitelisting m IP. If anyone has the same issue try it first. Go to mongodb and whitelist your IP in security -> network connections