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

144
Views
MongooseError: la consulta ya se ejecutó: Users.find ({nombre de usuario: 'b'})

Bloque de código:

 export const getFollowers = async (req,res) => { console.log(req.body) const profilename=req.body.profilename const followingarray = [] try{ await userModel.find({username:profilename},async (err,data)=> { const following = data[0].following following.map(async(whoimFollowing)=>{ await userModel.find({username:whoimFollowing},async (err,whoimFollowingdata)=> { console.log(whoimFollowingdata) followingarray.push(whoimFollowingdata) }) }) }).then((res)=> { }) }catch(e){ } }

Cuando agregué await a UserModel.find fue cuando se produjo este error, ¿cómo puedo evitar que ocurra este error?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

la función en sí es una devolución de llamada, por lo que agregar el asíncrono a getFollowers() es lo que está causando el error. Elimine el async con el try y la catch de getFollowers() y el código funcionará.

 export const getFollowers = () => { console.log(req.body) ... ... userModel.find({...,async (err,data) => {...}}) }
about 4 years ago · Juan Pablo Isaza Report
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!