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

186
Visualizações
In the browser showing empty while fetching data from mongodb and send to my getdata.ejs file

My index.js file get method

app.get('/getdata', function(req, res){
  var resultArray = [];
  mongo.connect(url, function(err, db){
    assert.equal(null, err);
    var cursor = db.collection('satyamsoft').find();
    cursor.forEach(function(doc, err){
      assert.equal(null, err);
      resultArray.push(doc);
      console.log(resultArray);
    });

  });

  res.render('pages/getdata', {holedata: resultArray});
});

My getdata.ejs file

<h2> Family Details </h2>
<ul>
    <% holedata.forEach(function(data) { %>
        <li><%= data.name %> - <%= data.title %> - <%= data.age %></li>
    <% }); %>
</ul>

After executing the get method in the console showing data which is fetch from mongodbColnose data

But in the web page showing empty enter image description here

Am i doing anything wrong. Please help me. Advance thanks.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This might help on client side in your .ejs file -

<script>
  var holedata = <%- JSON.stringify(holedata) %>;
</script>
about 4 years ago · Santiago Trujillo 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