From b816cb56dadb6a7b7af0910c79723e9c4cea26cb Mon Sep 17 00:00:00 2001 From: Jeff Date: Sat, 12 Oct 2024 17:43:30 -0400 Subject: [PATCH] Log even more garbage --- app/worker.ts | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app/worker.ts b/app/worker.ts index 357d171..5890528 100644 --- a/app/worker.ts +++ b/app/worker.ts @@ -136,19 +136,31 @@ export default function start(self: ServiceWorkerGlobalScope) { subscription: PushSubscription, db: ReturnType ) { - const response = await fetch(`${process.env.BASE_URL}/api/subscription/`, { - method: "POST", - body: JSON.stringify(subscription), - }) + try { + await sendMessage({ + message: `URL ${process.env.BASE_URL}/api/subscription/`, + }) - await sendMessage({ - message: `Response status ${response.status}`, - }) + const response = await fetch( + `${process.env.BASE_URL}/api/subscription/`, + { + method: "POST", + body: JSON.stringify(subscription), + } + ) - db.subscriptions.put({ - id: 1, - subscriptionId: (await response.json()).subscriptionId, - }) + await sendMessage({ + message: `Response status ${response.status}`, + }) + db.subscriptions.put({ + id: 1, + subscriptionId: (await response.json()).subscriptionId, + }) + } catch (error) { + await sendMessage({ + message: `ERRRROR ${(error as Error).toString()}}`, + }) + } } function putSubscription(subscription: PushSubscription, id: number) {