From 4283fe8a19adcc2b27b5282627f5a5bb3d5065b9 Mon Sep 17 00:00:00 2001 From: mohamad Date: Thu, 8 May 2025 23:28:33 +0200 Subject: [PATCH] Refactor axios error handling to throw new Error instances for better stack trace clarity; update component lifecycle methods in AccountPage, ListsPage, and ListDetailPage to use void for asynchronous calls; adjust polling interval type in ListDetailPage for improved type safety. --- fe/src/boot/axios.ts | 10 +++++----- fe/src/pages/AccountPage.vue | 2 +- fe/src/pages/GroupDetailPage.vue | 2 -- fe/src/pages/ListDetailPage.vue | 8 +++----- fe/src/pages/ListsPage.vue | 6 +++--- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/fe/src/boot/axios.ts b/fe/src/boot/axios.ts index 377a391..e8fa8bd 100644 --- a/fe/src/boot/axios.ts +++ b/fe/src/boot/axios.ts @@ -1,6 +1,6 @@ import { boot } from 'quasar/wrappers'; -import axios, { AxiosInstance } from 'axios'; -import { API_BASE_URL, API_VERSION, API_ENDPOINTS } from 'src/config/api-config'; +import axios from 'axios'; +import { API_BASE_URL } from 'src/config/api-config'; // Create axios instance const api = axios.create({ @@ -20,7 +20,7 @@ api.interceptors.request.use( return config; }, (error) => { - return Promise.reject(error); + return Promise.reject(new Error(String(error))); } ); @@ -56,11 +56,11 @@ api.interceptors.response.use( localStorage.removeItem('token'); localStorage.removeItem('refreshToken'); window.location.href = '/login'; - return Promise.reject(refreshError); + return Promise.reject(new Error(String(refreshError))); } } - return Promise.reject(error); + return Promise.reject(new Error(String(error))); } ); diff --git a/fe/src/pages/AccountPage.vue b/fe/src/pages/AccountPage.vue index 4ec021b..a8e99e8 100644 --- a/fe/src/pages/AccountPage.vue +++ b/fe/src/pages/AccountPage.vue @@ -259,6 +259,6 @@ const onPreferenceChange = async () => { }; onMounted(() => { - fetchProfile(); + void fetchProfile(); }); diff --git a/fe/src/pages/GroupDetailPage.vue b/fe/src/pages/GroupDetailPage.vue index 4e9e509..33d3414 100644 --- a/fe/src/pages/GroupDetailPage.vue +++ b/fe/src/pages/GroupDetailPage.vue @@ -35,7 +35,6 @@ import { ref, onMounted, computed } from 'vue'; import { useRoute } from 'vue-router'; import { apiClient, API_ENDPOINTS } from 'src/config/api'; -import { useAuthStore } from 'stores/auth'; import { copyToClipboard, useQuasar } from 'quasar'; interface Group { @@ -52,7 +51,6 @@ const props = defineProps({ }); const route = useRoute(); -const authStore = useAuthStore(); const $q = useQuasar(); const group = ref(null); diff --git a/fe/src/pages/ListDetailPage.vue b/fe/src/pages/ListDetailPage.vue index 3689299..e41c2c9 100644 --- a/fe/src/pages/ListDetailPage.vue +++ b/fe/src/pages/ListDetailPage.vue @@ -245,13 +245,11 @@ const list = ref({ const loading = ref(true); const error = ref(null); const addingItem = ref(false); -const pollingInterval = ref | undefined>(undefined); +const pollingInterval = ref(null); const lastListUpdate = ref(null); const lastItemUpdate = ref(null); const newItem = ref<{ name: string; quantity?: string }>({ name: '' }); -const editingItemName = ref(''); -const editingItemQuantity = ref(undefined); // OCR related state const showOcrDialog = ref(false); @@ -323,13 +321,13 @@ const checkForUpdates = async () => { const startPolling = () => { // Poll every 15 seconds - pollingInterval.value = setInterval(checkForUpdates, 15000); + pollingInterval.value = setInterval(() => void checkForUpdates(), 15000); }; const stopPolling = () => { if (pollingInterval.value) { clearInterval(pollingInterval.value); - pollingInterval.value = undefined; + pollingInterval.value = null; } }; diff --git a/fe/src/pages/ListsPage.vue b/fe/src/pages/ListsPage.vue index 0163716..05037db 100644 --- a/fe/src/pages/ListsPage.vue +++ b/fe/src/pages/ListsPage.vue @@ -196,9 +196,9 @@ const fetchLists = async () => { }; onMounted(() => { - fetchLists(); - fetchGroups(); - fetchGroupName(); + void fetchLists(); + void fetchGroups(); + void fetchGroupName(); }); const filteredLists = computed(() => {