byrdr
byrdr

Reputation: 5477

Accessing data from express route into view

I have a username JSON object which is being stored in as "bootstrappedUser". It is only defined on successful login. How would I make this available to the view (embed this object into the html source code) in ejs if it is defined?

app.get('/', function(req, res) {
    res.render('index.ejs',{
      bootstrappedUser: req.user
    });
});

Upvotes: 0

Views: 72

Answers (1)

tymeJV
tymeJV

Reputation: 104775

You can access this in EJS via:

<div>
    <%= bootstrappedUser %>
</div>

Upvotes: 3

Related Questions