Skip to content

Commit

Permalink
refactor: remove unused try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
VaneSkubic committed Feb 26, 2025
1 parent 1d0c81f commit f594062
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
20 changes: 7 additions & 13 deletions src/components/examples/api-example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/jsx-no-literals */
'use client';

import { useGetRandomFact } from '@/api/endpoints';
Expand All @@ -15,19 +14,14 @@ const ApiExample = () => {
});

const handleFetch = async () => {
try {
const res = await refetch();
const res = await refetch();

if (res.isSuccess && res.data) {
toast(t('toastTitle'), {
description: res.data.data.fact,
});
} else {
toast.error(t('toastError'));
}
} catch (error) {
toast.error(t('fetchError'));
console.error(error);
if (res.isSuccess && res.data) {
toast(t('toastTitle'), {
description: res.data.data.fact,
});
} else {
toast.error(t('toastError'));
}
};

Expand Down
1 change: 0 additions & 1 deletion src/i18n/en/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default {
apiExample: {
toastTitle: 'Random cat fact',
toastError: 'Failed to fetch a random fact!',
fetchError: 'An error occurred while fetching the fact',
submit: 'Call API',
},
} as const;
1 change: 0 additions & 1 deletion src/i18n/sl/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default {
apiExample: {
toastTitle: 'Naključno dejstvo o mačkah',
toastError: 'Pridobivanje dejstva ni uspelo!',
fetchError: 'Pri pridobivanju dejstva je prišlo do napake',
submit: 'Pokliči API',
},
} as const;

0 comments on commit f594062

Please sign in to comment.