I'm making a request to server to fetch some values and push them in an array
My GraphQL server's return me the array before the process ending, hence returns an empty array. Here a reproduction of the two methods I use :
1-
  var array= [];
        var auths= authModel.find({}).exec()
        .then(res => {
            res.map(el =>{ 
                array.push(el.ip)
            })
        }).then(() => array)
console.log(auths) // object Promise
console.log(array) // []
2-
  const auths= authModel.find().exec();
            if(!auths){ 
                throw new Error("Error while fetching users...")
            }
            console.log("auths:", auths) //  Promise { <pending> }
            return auths // on graphiql > "auths": { "ip": null }
What is going wrong ? How make my element returns when the promise is resolved ?
Any hint would be great, thanks
 
    