125
rated 0 times
[
126]
[
1]
/ answers: 1 / hits: 12892
/ 8 Years ago, sun, june 26, 2016, 12:00:00
I have the following code that checks to see if a user exists in a database...
router.post('/', function (req, res) {
User.findOne({
username: req.body.log_username,
password: req.body.log_password
}, function (err, docs) {
if (docs.length !== 0) {
console.log(user exists);
}
else {
console.log(no exist);
}
});
});
I have a home page that I want to send the user to if the login was a success. What should I put in the if
statement to send the use to another page, in this case, home.js
. home.js
has the following code in it...
var express = require('express');
var router = express.Router();
router.get('/', function (req, res) {
res.render('home', { title: 'Express' });
});
module.exports = router;
More From » node.js