Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

290
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda