Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!