I'm trying to learn every aspect of nodeJS and I was following this tutorial I tried to look at express and node's documentation but it doesn't explain what I want to know.
How do you know which parameters does a function pass?
Here's an example:
How do you know this returns a router?
module.exports = function(router) {
// http:localhost:3000/users
router.post('/users', function(req, res){
var user = new User();
user.username = req.body.username;
user.password = req.body.password;
user.email = req.body.email;
if (req.body.username == null || req.body.username == '' || req.body.password == null || req.body.password == '' || req.body.email == null || req.body.email == ''){
res.send('Ensure username, email and password were provided');
} else {
user.save(function(err){
if (err) {
res.send(' Username/email already exists ');
} else {
res.send('User created ')
}
});
}
});
/*console.log(router);
return router;*/
}
PS. I know I'm using router.post
but how can I know that.
PS2. I think it's not the same question as the one asking about JS.