title: How to send user to another page after login (node js)
body: <p>I have the following code that checks to see if a user exists in a database...</p>
  
  <pre><code>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");
          }
      });
  
  });
  </code></pre>
  
  <p>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 <code>if</code> statement to send the use to another page, in this case, <code>home.js</code>. <code>home.js</code> has the following code in it...</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  router.get('/', function (req, res) {
      res.render('home', { title: 'Express' });
  });
  
  module.exports = router;
  </code></pre>