From 7fffbf6d06acdabf8af41e8242b8105a12cc06c6 Mon Sep 17 00:00:00 2001 From: jzitnik-dev Date: Fri, 24 Oct 2025 08:31:47 +0200 Subject: [PATCH] chore: Logging --- server.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index 01fbf02..cbd06fa 100644 --- a/server.js +++ b/server.js @@ -45,13 +45,21 @@ app.post("/report", async (req, res) => { console.log(url) - const resp = await fetch(url, { - method: "POST", - headers: { - "Content-Type": "text/plain", - }, - body: `${content}\n\nClass: ${className}\nLocation: ${location}`, - }); + let resp; + + try { + resp = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "text/plain", + }, + body: `${content}\n\nClass: ${className}\nLocation: ${location}`, + }); + } catch (err) { + console.error('Fetch failed:', err.message); + console.error(err); + throw err; + } if (!resp.ok) { throw new Error(`Request failed`);