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

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -