Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a controller #22

Open
mateenNawaz86 opened this issue Jun 18, 2020 · 1 comment
Open

Add a controller #22

mateenNawaz86 opened this issue Jun 18, 2020 · 1 comment

Comments

@mateenNawaz86
Copy link

I am follow your course. This issue is create when i create a controller.

issue

@TalhaShafeeq
Copy link

i got the same error. I think the error is because the functions in controller does not have excess to the req and res actually . I still dont get why it runs in his tutorial video;. Anyway i solve this issue by declaring it in express app object

exports.signup = app.use((req, res) => {
console.log(req.body);
//res.send("data recieved");

if (req.body.Full_name == "" || req.body.Full_name == undefined) {
res.send("Missing Full Name: try Again");
return;
}
if (req.body.Email == "" || req.body.Email == undefined) {
res.send("Missing Email:: Try again");
return;
}
if (req.body.Password == "" || req.body.Password == undefined) {
res.send("Missing Password:: Try again");
return;
}
if (Evalid.validateEmailAddress(req.body.Email) === -1) {
res.send("Incorrect email :: Enter again");
return;
}
User.findOne({ Email: req.body.Email }).then((user) => {
// console.log(user);
if (user || user != null) {
return res.send("You are already registered...");
} else {
let NewUser = new User({
Full_name: req.body.Full_name,
Email: req.body.Email,
Password: req.body.Password,
});
NewUser.save()
.then((events) => {
res.json({ success: "You are registered:: Go to Login" });
})
.catch((err) => {
console.log(err);
// res.send("error");
res.end();
});
}
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants