From 29e12134157252e44d8b1daf939557645e7fa685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A4ssin?= Date: Tue, 15 Oct 2024 10:49:08 +0200 Subject: [PATCH] put stundenplan data in usestate to prevent refetching --- pages/stundenplan.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/stundenplan.vue b/pages/stundenplan.vue index bab01d9..c0d7793 100644 --- a/pages/stundenplan.vue +++ b/pages/stundenplan.vue @@ -32,8 +32,8 @@ const today = new Date().setHours(0, 0, 0, 0); const page = ref(1); - const groupedByDay = ref({}); - const data = ref([]); + const groupedByDay = useState('groupedByDay', (() => ({}))); + const data = useState('stundenplan', (() => [])); const schedule = computed(() => Object.values(groupedByDay.value)); watch(groupedByDay.value, (newVal) => { @@ -51,6 +51,8 @@ }); onMounted(async () => { + if (data.value.length !== 0) return; + const response = await $fetch( `https://corsproxy.io/?https%3A%2F%2Fselfservice.campus-dual.de%2Froom%2Fjson%3Fuserid%3D${username.value}%26hash%3D${password.value}%26t%3D${Math.floor(Date.now() / 1000)}` );