title: Unable to make HTTP post request
body: <p>I am trying to login using HTTP post request.</p>
  
  <p>app.js</p>
  
  <pre><code>//login
  app.get('/login', indexRouter); // call to login site
  app.post('/login',indexRouter); // post to /users/login site
  </code></pre>
  
  <p>users.js</p>
  
  <pre><code>router.get('/', function(req, res, next) {
      var message = '';
     var sess = req.session; 
  
     if(req.method == "POST"){
        var post  = req.body;
        var name= post.user_name;
        var pass= post.password;
  
        var sql="SELECT id, first_name, last_name, user_name FROM `users` WHERE `user_name`='"+name+"' and password = '"+pass+"'";                           
        db.query(sql, function(err, results){      
           if(results.length){
              req.session.userId = results[0].id;
              req.session.user = results[0];
              console.log(results[0].id);
              res.redirect('/users/home/dashboard');
           }
           else{
              message = 'Wrong Credentials.';
              res.render('index.ejs',{message: message});
           }
  
        });
     } else {
        res.render('index.ejs',{message: message});
     }         
  }); 
  </code></pre>
  
  <p>When I click on login, it directs me to <a href="http://localhost:3000/login" rel="nofollow noreferrer">http://localhost:3000/login</a> with an Eror 404 not found. I am loggin in from my homepage <a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a>. </p>
  
  <p>Am I doing the POST request wrongly ?</p>