Monday 1 May 2017

GET routes not called in express with html

I have a very simple app so I didn't think I needed a full-fledged front-end template like angular, and I didn't really want to use Jade

app.get('*', function(req, res) {
  res.sendFile(__dirname + '/public/index.html');
});

Basically I'm returning an html file, and I'm able to call other html files like

login.html
signup.html

But what confuses me is that my routes are not called. For example I send a GET request to /login but there is no "LOGIN GET" output

//Edit: even with req, res, I can delete this function below and still receive index.html

app.get('/login',function(req,res){ 
  console.log("LOGIN GET")
  res.sendFile( path.join( __dirname, 'public', 'login.html' ));    
});

How is login.html sent to the client if my route isn't called?



via testinggnitset ser

No comments:

Post a Comment