Render ejs template with the passed object

For some reason the following object isn't being passed through to the page correctly.

I'm able to console.log with this function, which returns a json object of the signed in user.

app.use(function(req, res, next){
console.log(req.user);
  next();
});

However, when I store it as a variable through the route it comes up as undefined. Any idea where the disconnect is?

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

The following results in bootstrappedUser in "bootstrappedUser is not defined "

<body ng-app="hcApp">
<script>
  console.log(bootstrappedUser);
</script>

Your latest snippet code is rendered by your server but is executed by the client's browser. Thus, your browser does not know what is bootstrappedUser.

But, if you do this:

<body ng-app="hcApp">
<script>
  console.log("#{bootstrappedUser}");
</script>
...

The server will render your code to (suppose bootstrapUser is equal to foo):

<body ng-app="hcApp">
<script>
  console.log("foo");
</script>
...

Now, the client's browser can executed the code without problem.

EDIT: Sorry, you are using EJS template (not jade). So, to render the variable: <%= bootstrappedUser %>:

<body ng-app="hcApp">
<script>
  console.log("<%= bootstrappedUser %>");
</script>
...