vic-3 vic-3 - 1 year ago 162
HTML Question

Passing a variable from node.js to html

I am trying to pass a variable from node.js to my HTML file.

app.get('/main', function(req, res) {
var name = 'hello';
res.render(__dirname + "/views/layouts/main.html", {name:name});


Answer Source

I figured it out I was able to pass a variable like this

<script>var name = "<%= name %>";</script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download