provide default empty notification array
This commit is contained in:
1 parent
4bc9f59d80
commit
83e1cb0304
1 file changed
+1
-3
@@ -538,14 +538,12 @@ class MonitorController {
|
|||||||
const monitorBeforeEdit = await this.db.getMonitorById(monitorId);
|
const monitorBeforeEdit = await this.db.getMonitorById(monitorId);
|
||||||
|
|
||||||
// Get notifications from the request body
|
// Get notifications from the request body
|
||||||
const notifications = req.body.notifications;
|
const notifications = req.body.notifications ?? [];
|
||||||
|
|
||||||
const editedMonitor = await this.db.editMonitor(monitorId, req.body);
|
const editedMonitor = await this.db.editMonitor(monitorId, req.body);
|
||||||
|
|
||||||
await this.db.deleteNotificationsByMonitorId(editedMonitor._id);
|
await this.db.deleteNotificationsByMonitorId(editedMonitor._id);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
notifications &&
|
|
||||||
notifications.map(async (notification) => {
|
notifications.map(async (notification) => {
|
||||||
notification.monitorId = editedMonitor._id;
|
notification.monitorId = editedMonitor._id;
|
||||||
await this.db.createNotification(notification);
|
await this.db.createNotification(notification);
|
||||||
|
|||||||
Reference in new issue
Block a user