diff --git a/Server/controllers/monitorController.js b/Server/controllers/monitorController.js index 582625e32..f157b2fdd 100644 --- a/Server/controllers/monitorController.js +++ b/Server/controllers/monitorController.js @@ -402,14 +402,13 @@ const editMonitor = async (req, res, next) => { await req.db.deleteNotificationsByMonitorId(editedMonitor._id); - if (notifications && notifications.length !== 0) { - await Promise.all( + await Promise.all( + notifications && notifications.map(async (notification) => { notification.monitorId = editedMonitor._id; await req.db.createNotification(notification); }) - ); - } + ); // Delete the old job(editedMonitor has the same ID as the old monitor) await req.jobQueue.deleteJob(monitorBeforeEdit);