blob: c061d9284f3c84bd49ef479fe7702a0597656b17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
export default function useFetchFavourites() {
const scheduleStore = useScheduleStore();
const errorStore = useErrorStore();
const config = useRuntimeConfig();
useFetch(config.public.baseURL + '/schedule', {
method: 'GET',
server: false,
lazy: true,
onResponse: ({ response }) => {
if (!response.ok) {
if (response.status === 401) {
navigateTo({ name: 'login', state: { error: 'Sorry, your session has expired' } });
} else {
errorStore.setError(response._data.message || 'An unknown error occurred');
}
}
if (response._data) {
scheduleStore.setSchedule((response._data as any).data.schedule);
errorStore.setError("Schedule set");
} else {
errorStore.setError("Invalid response returned by server");
}
},
});
}
|