I have been attempting to map a group of user documents within mongoDB. Here's the code snippet I've written for this purpose.
User.retrieveUsers = function() {
return new Promise(async (resolve, reject) => {
try {
let users = await ValidUser.find()
users.map(function(user) {
return {
username: user.username,
email: user.email
}
})
console.log(users)
resolve(users)
} catch {
reject("404")
}
})
}
After examining the code, it appears that instead of mapping the array as intended, it only displays the original data stored.