I am trying to push data to a view in node and i try to diplay it.
This is the line in routes.js:
res.render('target.ejs', {data:"user"});
And this is the ejs
file:
<html>
<head>
</head>
<body>
<p> <h1>{{ data }}</h1> </p>
</body>
</html>
The user
variable i passed in the res.render()
is a string.
However, this is what i view when rendering the webpage:
{{ data }}
If you want to display rendered data in ejs file, use this way
<h1><%= data %></h1>
This should display the string "user". In your routes.js file, If user is a variable and holds some data you should render it like this
res.render('target.ejs', {data: user});