on-internet
← Community

NodeJS, getting username of logged in user within route

Stack Overflow ·

I am getting in to NodeJS and have followed some video tutorials for making stuff, to understand NodeJS and Express. It turned more in to copying as little were explained, so tried to make my own thing using what I learned and so on. Making a simple login function with PassportJS, ExpressJs and Mongoose. The login and stuff works, and I can get the username of the currently logged in user and display it if I define it within the main app.js using this: app.get("/stuff", (req,res) => { res.render("stuff.html", {username:req.user.username}); }); Now if I want to make nice and structured by using

Comments

Sign in or sign up to comment and upvote.

No comments yet.