Skip to content

Commit

Permalink
Revert "changed url and added more error logging"
Browse files Browse the repository at this point in the history
This reverts commit bb1d513.

revert on commit bb1d513.
  • Loading branch information
PowerMaxZ committed Oct 13, 2023
1 parent bb1d513 commit ecfbc52
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/helpers/useFetchData.ts
Original file line number Diff line number Diff line change
@@ -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}`;
Expand All @@ -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;
Expand Down

0 comments on commit ecfbc52

Please sign in to comment.