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

192
Vistas
.push() not pushing into array with mongodb

im trying to map through users in a database and .push() each of them into an array so i cant send it as a response to the client but its returning an empty object im not sure if the data has been pushed and its returning before the array is updated?

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)=>{
                  
                  const users_found = await userModel.findOne({ username: whoimFollowing }).then(
                   
                    (data)=> {   
                        console.log(data)
                        followingarray.push(data)})
                 
               
                 
                
            })
           await res.status(208).json(followingarray)
        })
            
                }catch(e){
                   
                }
            }
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