I keep getting this MongoDB error, this is my connection to mongodb. I am trying to make a register and login application
const { MongoClient } = require('mongodb');
const uri = "mongodbconnection";
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
client.connect(error => {
const collection = client.db("test").collection("devices");
// perform actions on the collection object
client.close();
});
this is the signup application
router.post('/register', async (req, res) => {
//hashing the password
const hashedPwd = await bcrypt.hash(req.body.password, saltRounds);
//using passport-local for authentication
const newUser = new User({
email: req.body.email,
password: hashedPwd
})
try {
await newUser.save()
console.log("new user created")
} catch (error) {
if (error) {
console.log(error)
}
}
})