0
Ich versuche, ein Anmeldefenster zu erstellen. Mein Code ist einfach.Node.js undefined Eigenschaften
var employees = {
\t '1' : {
\t \t firstName: '',
\t \t lastName: '',
\t \t login: 'qwerty',
\t \t password: '12345',
\t },
\t '2' : {
\t \t login: 'asdfg',
\t \t password: '12345',
\t },
};
app.post('/main', function(req, res) {
\t if (!req.body) return res.sendStatus(400);
\t \t console.log(req.body);
\t for (var key in employees) {
\t \t console.log(key['login']);
\t \t console.log(key['password']);
\t \t if ((key.login == req.body.login) && (key.password == req.body.password)) {
\t \t \t \t res.render('main');
\t \t } else {
\t \t \t app.get('/', function(req,res) {
\t \t \t \t res.send(createIndexPage());
\t \t \t });
\t \t };
\t };
});
Warum key.login und key.password undefined zurückkehren? Und warum sonst Block nicht ausgeführt wird, wenn if-Anweisung falsch ist?
Danke, es funktioniert. Aber warum, wenn ich falsche Datenseite gebe, ist unendlich laden und sonst Block läuft nicht? –