node.js - I want to render the data with the HTML file -
routes.get('/agents',function(req,res,next){ var sess = req.session; var userdata = sess.username; console.log("data coming here "+userdata); res.sendfile(__dirname + '/views/agents.html',[{"sessiondata":userdata}]); });
i want send data file , use data in html file. way this.please let me.
you should use templating engine render data. ejs , jade work great , quite popular, you'll find plenty of resource learn how use it. learnjade 1 learn.
using jade :
routes.get('/agents', function(req, res, next) { var sess = req.session; var userdata = sess.username; console.log("data coming here " + userdata); res.render("agents.jade", {"sessiondata": userdata, "doesitwork": "yeah"}); });
Comments
Post a Comment