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

141
Vistas
JavaScript & monk: turn result from find() to array

I am working on an assignment that required us to fetch data of newsfeeds from a MongoDB database using monk. And put them onto a webpage. I am planning to get the data needed in an array. But when I run this, it responses

newsList.find(...).toArray is not a function

I have searched for a solution for that for a while. And I can't really find one.

app.get('/newsfeed.html', function(req, res){
  var db = req.db;
  var newsList = db.get('newsList');
  var newsArray = newsList.find({}, ['-_id', 'headline', 'date', 'content', '-comments']).toArray();
  var response = "";
  for (let i = 0; i < newsArray.length; i++){
    response += newsArray[i];
  }
  res.send(response);
});
about 4 years ago · Juan Pablo Isaza
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