saad khan
KPCKevin Powell - Community
•Created by saad khan on 2/20/2025 in #back-end
sending first data in mongodb
hi guys
in what cases in this
const registration = async (req, res) => {
try {
console.log(req.body);
const { email, name, phone, gender, password } = req.body;
const userExist = await User.findOne({ email });
if (userExist) {
return res.status(400).json({ message: "User already exists" });
}
const newUser = await User.create({ email, name, phone, gender, password });
res.status(200).json({ message: "Registration successful", user: newUser });
} catch (error) {
console.error("Error in registration:", error);
res.status(500).json({ message: "Internal Server Error" });
}
};
the part after console.log(req.body) is not working and returns the massage "internal server error" in postman
i have created my cluster and database successfully my mongodb is connected properly and i have checked all the other things stills can't find the solution
18 replies