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

438
Views
how to display data to ejs from API (express js)

Using express js, i want to render json that has been produced by my to ejs file.

here is my controller that produce json

const getAllQuotes = asyncWrapper(async (req, res) => {
  const quotes = await qSchema.find({});
  res.status(200).json({ quotes });
});

I want to pass the JSON from controller to my router below, then what my router does is bring the data and show the data to admin page

adminRoute.get('/', async (req, res) => {
  //what should i type here?
        res.render("admin")
})

or maybe my question is about how the data can be thrown/passed in between js file

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Don't make HTTP requests from your server back to your server.

You have a function that gets your data. Use that function.

adminRoute.get('/', async (req, res) => {
    const quotes = await qSchema.find({});
    res.render("admin", { quotes });
})
about 4 years ago · Santiago Gelvez 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!