From 868571f1a82c6c8c0fea0c4670151adbc120ff83 Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 18 Jul 2025 16:09:30 +0100 Subject: [PATCH] logging on requesst --- templates/base.html | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/templates/base.html b/templates/base.html index 1c7a526..54e5d8a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -70,9 +70,26 @@ event.preventDefault(); fetch('{{ url_for("send_test_notification") }}', { method: 'POST' - }).then(response => response.json()) - .then(data => console.log(data.message)) - .catch(err => console.error('Error sending test notification:', err)); + }).then(response => { + console.log('Response status:', response.status); + console.log('Response headers:', response.headers); + return response.text().then(text => { + console.log('Response body:', text); + try { + return JSON.parse(text); + } catch (e) { + console.error('Failed to parse JSON:', e); + throw new Error('Server returned non-JSON response'); + } + }); + }).then(data => { + console.log('Parsed data:', data); + if (data.message) { + console.log(data.message); + } + }).catch(err => { + console.error('Error sending test notification:', err); + }); }); }