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

291
Views
how do i make my journal work in a ejs file?

I'm trying to make a journal but I'm stuck, I'm trying to make a for loop that posts the posts that I compose, in an array on the home page. I get connection between the app file and the ejs file because the inputs shows up when i log it in the terminal, I just can't get it to show up on the home page. I just want the title of the input to show up but i keep getting "SyntaxError: Unexpected token ')' in /user Desktop/frontEndNode-master/views/home.ejs while compiling ejs"..

<%- include("include/header"); -%>

<h1>Home</h1>
<P> <%= startingContent %> </P>
<%- console.log(posts);-%>


<%- include("include/footer"); -%>


const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");
const { redirect } = require("express/lib/response");

const homeStartingContent =
  "Lacus";
const aboutContent =
  "Hac habitass";
const contactContent =
  "Scelerisque";

const app = express();

app.set("view engine", "ejs");

app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));

const posts = [];

app.get("/", (req, res) => {
  res.render("home",{ startingContent: homeStartingContent , posts:posts});
  posts: [
{posts: posts},
{posts: posts}
  ]
  //console.log(posts);
});

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

0

There's an extra ) somewhere.

To render HTML posts, you need to loop through array that you pass and extract values you need, where you also construct HTML. Here's an example of looping through an object array with forEach and creating an <ul>

<ul>
 <% posts.forEach(function(post, i) { %>
    <li>Post <% i+1; %>. <%= post.name %> Date: <%= post.date %></li>
 <% }); %> 
</ul>
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!