From 99d805da8611494d6c5cc12ace739ade8566fa43 Mon Sep 17 00:00:00 2001 From: Ilija Vukotic Date: Tue, 8 Oct 2024 11:40:31 -0500 Subject: [PATCH] Refactor debug logs in alarms.js --- routes/alarms.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/routes/alarms.js b/routes/alarms.js index 8b3567a..66b6380 100644 --- a/routes/alarms.js +++ b/routes/alarms.js @@ -226,10 +226,13 @@ router.post('/category', jsonParser, async (req, res) => { body: b, refresh: true, }); - console.log('Category added.'); - console.debug(response); - await loadAlarmTopology(); - res.status(200).send('OK'); + console.log(`Category adding result: ${response.result}`); + if (response.result === 'created') { + await loadAlarmTopology(); + res.status(200).send('OK'); + } else { + res.status(500).send(response.result); + } return; } catch (err) { console.error(err); @@ -346,7 +349,7 @@ router.delete('/', async (req, res) => { refresh: true, }); console.log(`delete response: ${response}`); - if (response.body.deleted > 0) { + if (response.result === 'deleted') { await loadAlarmTopology(); res.status(200).send('OK'); } else {