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.
This commit is contained in:
parent
0dbee3bb4b
commit
4283fe8a19
@ -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)));
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -259,6 +259,6 @@ const onPreferenceChange = async () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchProfile();
|
||||
void fetchProfile();
|
||||
});
|
||||
</script>
|
||||
|
@ -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<Group | null>(null);
|
||||
|
@ -245,13 +245,11 @@ const list = ref<List>({
|
||||
const loading = ref(true);
|
||||
const error = ref<string | null>(null);
|
||||
const addingItem = ref(false);
|
||||
const pollingInterval = ref<ReturnType<typeof setInterval> | undefined>(undefined);
|
||||
const pollingInterval = ref<NodeJS.Timeout | null>(null);
|
||||
const lastListUpdate = ref<string | null>(null);
|
||||
const lastItemUpdate = ref<string | null>(null);
|
||||
|
||||
const newItem = ref<{ name: string; quantity?: string }>({ name: '' });
|
||||
const editingItemName = ref('');
|
||||
const editingItemQuantity = ref<string | undefined>(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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -196,9 +196,9 @@ const fetchLists = async () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchLists();
|
||||
fetchGroups();
|
||||
fetchGroupName();
|
||||
void fetchLists();
|
||||
void fetchGroups();
|
||||
void fetchGroupName();
|
||||
});
|
||||
|
||||
const filteredLists = computed(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user