I am working on backend using MERN i have created the route to send the verification mail but when i try to hit the apiendpoint in post it gives me error
Cannot POST /api/users/sendVerificationMail
router.use("/api/users",websiteUserRoutes)
router.get("/sendVerificationMail",auth,UserController.sendVerificationMail)
module.exports.sendVerificationMail = async (req,res)=>{
let id = req.userId;
let existingDocument = await User.findById(id);
if (!existingDocument) {
return res.send({ error: true, msg: "User not found." });
}
console.log(existingDocument.email)
let random = await sendMail(existingDocument.email,"verify",id)
console.log(random);
res.send({id,random});
}
DATABASE Fields
DATABASE FIELD
I wanted to know why this happening also i need to send userId or mongodb Unique id in params or in query
so that this endpoint start working
1