I am trying to take a variable I've sent to my Pug page from Node.js and place it inside a javascript variable inside of a pug script tag. (Sorry if that is confusing) My node.js code is as follows:
app.get('/profile', function (req, res) {
var session = req.session;
res.render('./login.pug', { username: session.uniqueID });
});
When I use the variable in my pug page code like this
input(type='text', id='username', value=username)
it works fine. The value will be changed to the username that the variable holds. But when I try to put the same value in my script tag such as
script.
var currentuser = username;
the browser console will tell me that username is undefined. How do I properly pass the value of the variable username inside the script tag? Also is there a way to pass the variable username into an external js file as well? Thank you in advance for your help!