Reputation: 1793
routes.get('/agents',function(req,res,next){
var sess = req.session;
var userData = sess.username;
console.log("Data is coming here "+userData);
res.sendFile(__dirname + '/views/agents.html',[{"sessionData":userData}]);
});
I want to send the data with the file and use the data in html file. Any way to do this.Please let me.
Upvotes: 1
Views: 208
Reputation: 153
You should use a templating engine to render your data. EJS and Jade work great and are quite popular, you'll find plenty of resource to learn how to use it. LearnJade is a good one to learn.
Using Jade :
routes.get('/agents', function(req, res, next) {
var sess = req.session;
var userData = sess.username;
console.log("Data is coming here " + userData);
res.render("agents.jade", {"sessionData": userData, "doesItWork": "yeah"});
});
Upvotes: 2