I expect to push element in array but when I log, the array is empty how to solve that this is the code please help
let recipient = [] // this is the array
student.legalGuardians.map(async (legalGuardians) => {
let user = await getUserByNationalIdOrPhoneNumberOrEmail(
legalGuardians.nationalId,
legalGuardians.phoneNumber,
legalGuardians.email
);
if (!user || user == false) {
return;
}
if (user.firebaseToken != null || user.firebaseToken != undefined) {
Notifystatus = await sendNotificationforUser(
subject,
body,`
`data,
user.firebaseToken
);
}
recipient.push({
userId: user._id,
Notifystatus: Notifystatus,
studentId: student._id,
});
console.log(recipient);
});
console.log(recipient)
// output []