0

Note: Inside forEach block the UserInfo array contains a value

    const UsersInfo = []

     // product.users it's array
   
      product.users.forEach(async(u)=> {

        console.log(u.userID)
        us =await User.findOne({_id: u.userID})
         
    })
    console.log(UsersInfo) 
  • Aside from the duplicate: You don't modify the array inside the loop. – Quentin Mar 29 '22 at 12:58
  • 1
    Note that idiomatic JS reserves variable names starting with capital letters for classes / constructor functions. It isn't a great idea to use that naming convention for an array. – Quentin Mar 29 '22 at 12:59

0 Answers0