From b9a3768f4cfab9e1fd970c32b21f52f5c3d1bdf0 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Mon, 3 Feb 2025 22:53:41 -0500 Subject: [PATCH] Caught errors on webpush --- notifications.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/notifications.js b/notifications.js index c9e131b..e832156 100644 --- a/notifications.js +++ b/notifications.js @@ -4,11 +4,16 @@ const { Expo } = require('expo-server-sdk'); const webPush = require('web-push'); const sendWebNotification = async (subscription, title, body) => { - const payload = JSON.stringify({ - title, - body - }); - webPush.sendNotification(subscription, payload); + try { + const payload = JSON.stringify({ + title, + body + }); + webPush.sendNotification(subscription, payload); + } catch (error) { + console.error('Error sending web notification', error); + } + } // Expo API to send push notifications, this code was a provided snipped