From 9e3348d9b69c767cc685e6c03ddf4f5548e49c20 Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 18 Jul 2025 16:58:42 +0100 Subject: [PATCH] notification --- templates/base.html | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/templates/base.html b/templates/base.html index 54e5d8a..51147bc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -127,13 +127,29 @@ } function saveSubscription(subscription) { + console.log('Attempting to save subscription...'); fetch('/save-subscription', { method: 'POST', headers: { - 'Content-Type': 'application/json', - 'Authorization': 'Basic {{ session.auth_credentials }}' + 'Content-Type': 'application/json' }, body: JSON.stringify(subscription) + }) + .then(response => { + if (response.ok) { + console.log('Subscription saved successfully.'); + return response.json(); + } else { + console.error('Failed to save subscription. Status:', response.status); + response.text().then(text => console.error('Server response:', text)); + throw new Error('Failed to save subscription.'); + } + }) + .then(data => { + console.log('Server response on save:', data); + }) + .catch(err => { + console.error('Error during saveSubscription fetch:', err); }); }