From 29cfa86b5f4844634bc6d48171daed58554f2ef9 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Wed, 18 Dec 2024 12:36:38 +0100 Subject: [PATCH] returned try catch --- src/Python/flask/web/static/script.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Python/flask/web/static/script.js b/src/Python/flask/web/static/script.js index 109916d..de56ad4 100644 --- a/src/Python/flask/web/static/script.js +++ b/src/Python/flask/web/static/script.js @@ -24,11 +24,15 @@ document.querySelectorAll(".btn").forEach(button => { // Fetch data from the server async function fetchData() { + try{ const response = await fetch("/data"); const data = await response.json(); return data; + } catch (error) { + console.error("Error:", error); } + // Parse the data and show it on the website async function parseData() { const data = await fetchData();