How to access the variable passed through res.renderer?

I'm passing a variable to my template renderer in ExpressJs like so:

index.js

app.get('/simple_view/', function(req, res, next){
  title='A TITLE';
  res.render('simple', {
          title: title
       });
    });  

I would like to access the title variable in a JS script on my template page, but I'm getting Uncaught ReferenceError: title is not defined error.

simple.pug

script.
   console.log(title);

How can I solve this?



Read more here: https://stackoverflow.com/questions/68473734/how-to-access-the-variable-passed-through-res-renderer

Content Attribution

This content was originally published by IMAGINE PRODUCTIONS at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: