Here is a function called sendEmail:
public async sendEmail (log: LogMessage): Promise<void> {
nodemailer.createTestAccount(async () => {
return ServiceFactory.getSystemService().getNetworkPreferences().then(async (networkPreferences) => {
....
I am looking to incorporate this function into a for loop:
for (const log of logs) {
const timestamp = moment(log.creationDate)
const startTime = new Date(Date.now())
if ((timestamp.diff(startTime)) >= rule.miliSecond && category.includes(log.category)) {
return this.sendEmail(log)
}
}
The issue I am facing is that I cannot remove "return this.sendEmail(log)" since the function returns a Promise. However, the loop only runs once with the first log before terminating. How can I make sure the function is executed within the loop?