From ecfbc521d913dc478ce935f6bc7f3b4967e6babf Mon Sep 17 00:00:00 2001 From: PowerMaxZ Date: Fri, 13 Oct 2023 10:03:25 +0000 Subject: [PATCH] Revert "changed url and added more error logging" This reverts commit bb1d513e6821e14b7a16d4e64f748e33e8b64c54. revert on commit bb1d513e6821e14b7a16d4e64f748e33e8b64c54. --- src/helpers/useFetchData.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/helpers/useFetchData.ts b/src/helpers/useFetchData.ts index a726573..0f4fece 100644 --- a/src/helpers/useFetchData.ts +++ b/src/helpers/useFetchData.ts @@ -1,6 +1,6 @@ import { useQuery } from 'react-query'; -const BASE_URL = "http://193.40.11.233:5000/"; +const BASE_URL = "http://193.40.11.233/db-api/"; export function useFetchData(endpoint: string) { const fullUrl = `${BASE_URL}${endpoint}`; @@ -11,24 +11,20 @@ export function useFetchData(endpoint: string) { 'Accept': 'application/json', } }); - const responseData = await response.json(); - console.log('Fetched data from:', fullUrl, responseData); if (!response.ok) { - throw new Error(`Network error: ${response.status} - ${JSON.stringify(responseData)}`); + const text = await response.text(); + throw new Error(`Network error: ${response.status} - ${text}`); } - return responseData; + return response.json(); }, { refetchOnWindowFocus: false, refetchOnReconnect: false }); - if (isLoading) { - console.error('Error, isLoading'); - return {}; - } + if (isLoading) return null; if (isError) { - console.error('Error fetching data:', error); - return {}; + console.error(error); + return null; } return data;