Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

315
Views
Error while rendering EJS file, browser not recognizing local JSON properties

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)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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...

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!