From ad5acf85f9090da48e8691b984d5b4e2f963259a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Krau=C3=9Fer?= Date: Mon, 4 May 2026 23:59:17 +0200 Subject: [PATCH] fixed fetch bug --- cnn_website/src/Bird_CNN.jsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cnn_website/src/Bird_CNN.jsx b/cnn_website/src/Bird_CNN.jsx index ce7ac00..2bbdf8e 100644 --- a/cnn_website/src/Bird_CNN.jsx +++ b/cnn_website/src/Bird_CNN.jsx @@ -61,26 +61,26 @@ function Bird_CNN() { method: "POST", body: formData, }); + + if (!response.ok) { + setError(true); + return; + } + else { + setError(false); + } + + const result = await response.json(); + + setBirdClass(result["class"]); + const confidence = result["confidence"]; + setConfidence(`${Math.round(confidence * 100)}%`); } catch (e) { setError(true); - return; } finally { setLoading(false); } - - if (!response.ok) { - setError(true); - return; - } - else { - setError(false); - } - - const result = await response.json(); - setBirdClass(result["class"]); - const confidence = result["confidence"]; - setConfidence(`${Math.round(confidence * 100)}%`); }; return (