From c09fbe567162fdfd5eafe9f7413e23c32efc04cf Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 29 May 2024 12:32:05 +0300 Subject: [PATCH] try to fix logged error: Subscription update successful 0c8nsU_N6RQPMalxp5ep_w . Total subscriptions: 2 TypeError: Cannot read properties of null (reading 'pushSubscription') --- pages/api/notify.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/notify.ts b/pages/api/notify.ts index 354fea5..d34ddf3 100644 --- a/pages/api/notify.ts +++ b/pages/api/notify.ts @@ -152,7 +152,7 @@ export const sendPush = async (id, title, message, actions) => { where: { id } }) - if (Array.isArray(publisher.pushSubscription) && publisher.pushSubscription.length) { + if (publisher.pushSubscription && Array.isArray(publisher.pushSubscription) && publisher.pushSubscription.length) { for (const subscription of publisher.pushSubscription) { await webPush .sendNotification(