gpt4 book ai didi

javascript - 我如何知道应该在 NodeJS 中使用哪些参数

转载 作者:行者123 更新时间:2023-12-03 05:03:37 25 4
gpt4 key购买 nike

我正在尝试学习nodeJS的各个方面,并且我正在遵循本教程,我尝试查看express和node的文档,但它没有解释我想知道的内容。

如何知道函数传递哪些参数?

这是一个例子:

你怎么知道这会返回一个路由器?

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。我知道我正在使用 router.post 但我怎么知道这一点。PS2。我认为这与询问 JS 的问题不是同一个问题。

最佳答案

您应该看看the Express docs 。另外,debugging your app可能是一个好的开始。

已编辑:正如其他人提到的,您可以简单地使用 console.log

关于javascript - 我如何知道应该在 NodeJS 中使用哪些参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42104597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com