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;