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 + \"/view
Other than those on the top, you can use JavaScript to fetch the details from the server. html file
server.js
app.get('/test',(req,res)=>{
//res.sendFile(__dirname +"/views/test.html",);
res.json({title:"api",message:"root"});
})
app.get('/render',(req,res)=>{
res.sendFile(__dirname +"/views/test.html");
})
The best answer i found on the stack-overflow on the said subject, it's not my answer. Found it somewhere for nearly same question...source source of answer