From a9c2df766e77071ba23ee179866bf5a59663de41 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Tue, 17 Dec 2024 14:27:59 +0100 Subject: [PATCH] #34 - handle error --- src/views/Notifications.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/views/Notifications.vue b/src/views/Notifications.vue index a359917..090e5c8 100644 --- a/src/views/Notifications.vue +++ b/src/views/Notifications.vue @@ -173,15 +173,17 @@ function readAll() { } function read(notification) { - if (!notification.isRead) { - console.log(notification); + if (!notification.id) { + console.error("Couldn't change notification status because it has no id."); + } else if (!notification.isRead) { api .readNotification(notification.id) .then((res) => { router.push(toPath(notification.location.href)); }) - .catch((err) => console.log(err)); + .catch((err) => console.error("Notification could not be read.", err)); } + router.push(toPath(notification.location.href)); } function toPath(string) {