Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

280
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda