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

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

0

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

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