Thursday, 11 October 2018

How does this route know req.user data?

Hi allThis is really confusing me. I hope you can help me.I have a link on a dashboard which allows the user to view his profile:/profile I have a route for the URL:app.get('/profile', isLoggedIn, function(req, res) { res.render('profile.ejs', { user: req.user, isLoggedIn: req.isLogged }); }); profile.ejs then correctly displays the user profile data.Here's my question:If I just click on a plain HTML link /profile, surely there is no req data, so how does passing user: req.user to profile.ejs work?I thought req was only populated if I submit a form or pass variable via the URL.Thanks for your guidance.

Submitted October 11, 2018 at 07:29PM by just_tech_stuff

No comments:

Post a Comment