this is my ejs code:
<h1>Welcome to website</h1>
<%-include('post')%>
<%=posts%>
this is my action/controller function:
module.exports.postpost = (req,res)=>{
postschema.create({
content:req.body.content,
user:req.user._id
},(err,doc)=>{
if(err)console.log(err);
console.log(doc);
});
postschema.find({},(err,doc)=>{
if(err)console.log(err);
console.log(doc);
let mydata = {
posts:doc
}
return res.render("user_profile",mydata);
});
}
this is the error im getting:
eReferenceError: /Users/aman/Documents/Web development /projects/relating database/views/user_profile.ejs:3
1| <h1>Welcome to website</h1>
2| <%-include('post')%>
3| <%=posts%>
posts is not defined at eval (eval at compile (/Users/aman/Documents/Web development /projects/relating database/node_modules/ejs/lib/ejs.js:662:12), :15:25)
Did you set your templating engine as Ejs in app.js.
You may also define your views directory in the app.js.
Hope it works for you...