我正在尝试使用 Node.js 制作登录系统,但我不知道如何使用 fs 模块(第 7 行)中的变量。响应是“无法读取未定义的属性‘密码’”
app.post('/auth', function(request, response) {
var contents = fs.readFileSync(__dirname + '/database/clans.json');
var jsonContent = JSON.parse(contents);
var post_password = request.body.password;
var post_username = request.body.username;
var password = jsonContent._post_username_.password; //Issue is here
// if(post_password == ){
// }else{
// }
response.send(password)
// response.send(request.body.username);
});
<div class="login-form">
<h1>Clan Login</h1>
<form action="auth" method="POST">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="submit">
</form>
</div>
JSON文件:
{
"rtv":{
"username":"rtv",
"password":"rtv2019"
}
}
慕的地8271018
相关分类