I'm not able to console log the specific data from a field but I'm able to console the result from an object. For example, when I console.log(enrollRegInfo), I get the data return, but when I console.log(enrollRegInfo.studentid), I get undefined
const enrollInfo = await Registration.findOne({_id:{"$eq": id}})
const enrollRegInfo = enrollInfo.registrant.map((record) => {
return {
studentid: record.studentID,
studentname: record.studentName
};
});
//data returned in this line
console.log(enrollRegInfo)
[
{
studentid: '6506de7b0d32492c878307a1992f54e8',
studentname: 'Mary Jane'
}
]
//get undefined in this line
console.log(enrollRegInfo.studentid,enrollRegInfo.studentprincipalname)
undefined, undefined
Thanks