I'm using nodejs and Edge template to render dynamic data in HTMl elements , fed up with different solution but nothing seems working for me. I have used #App.locals, to declare the variable but getting function anonymous. So stick to original i want to return some data in x variable. I would appreciate your response , thank you.
code snippet : Example 1
const app =require(express)
const edge = require('edge.js')
app.use('*', (req, res, next) => {
edge.global('id', req.session.userId)
next()
});
here i'm getting an error as global is not a function
no luck so i run to different code
Example 2 :
const app =require(express)
var xvariable = {
id:"1"
}
app.use('*', (res, req, next) => {
app.locals = xvariable
console.log(id) // expecting output as 1 but getting function[asynchronous]
next()
});