Router.get firing twice for the same route on page load

In my router

Router.get(‘/login’, IndexController.login);

In my controller

exports.login = (req,res,next)=>{
console.log(‘login get’);
res.render(‘main/login’,{pageTitle: ‘Login’});

};

The console logs login get twice, meaning that this is called twice. If I remove the render call then it is logged only once. I have been trying to debug for several days now but still cant seem to figure this one out. When using a curl request from another terminal the log is seen only once as well, but using chrome/firefox/IE yields the double or sometimes triple log call. I don’t see this behaviour with POST calls however. -EJS -EXPRESS -Node

UPDATE In chrome dev tools, after inspecting the network tab, I only see 1 GET request being made for the page.

Author: Fantashit

2 thoughts on “Router.get firing twice for the same route on page load

  1. My guess is that your view is making a request you were not planning on. Maybe a favicon or an xhr reuest? I would check your browser network tab.

Comments are closed.