Home > OS >  How can I access this variable inside my function, so I can output it into my ejs file?
How can I access this variable inside my function, so I can output it into my ejs file?

Time:05-27

I'm trying to output this function into my ejs file. But I don't know how to access the output variable?

function ejsoutput(json){
  var output = json;
};

app.get('/',(req, res, next) => {
    res.render('index', { leaderboard: output });  
});

CodePudding user response:

You can try something like this. It might work,

var output = null;
function ejsoutput(json){
  output = json;
};

app.get('/',(req, res, next) => {
    res.render('index', { leaderboard: output });  
});
  • Related