I'm trying to read a JSON file from my database. Here is the rendered page.
<% newcompose.forEach(function(post){ %>
<h1><%= post.caption %></h1>
<p><%= post.text %></p>
<% }); %>
And this is how i'm passing the value into newcompose.
Post.find({}, function(err, posts){
if(!err){
res.render("home", {newcompose: posts});
}
});
It says newcompose not defined but if I add <% var newcompose; %> to home then it says forEach not defined. also I'm using mongoose.
postshas a value