From 47ec91cb44eb39efe21c21ee552f0bfe5add9e63 Mon Sep 17 00:00:00 2001 From: ppodds Date: Thu, 1 Feb 2024 17:19:49 +0800 Subject: [PATCH] refactor(frontend): remove unless fetch key --- apps/frontend/composables/useCache.ts | 33 --------------------------- apps/frontend/pages/courses/[id].vue | 9 +++----- 2 files changed, 3 insertions(+), 39 deletions(-) diff --git a/apps/frontend/composables/useCache.ts b/apps/frontend/composables/useCache.ts index 7c80969f..53bf0d73 100644 --- a/apps/frontend/composables/useCache.ts +++ b/apps/frontend/composables/useCache.ts @@ -72,36 +72,3 @@ export const useCache = async (): Promise => { } throw new Error("This should never happen."); }; - -// export const useCache = async (): Promise => { -// const config = useRuntimeConfig(); -// const [{ data: courses }, { data: colleges }, { data: departments }] = -// await Promise.all([ -// $fetch>(`${config.public.apiBaseUrl}/courses`), -// $fetch>(`${config.public.apiBaseUrl}/colleges`), -// $fetch>( -// `${config.public.apiBaseUrl}/departments`, -// ), -// ]); -// if (!courses) -// throw createError({ -// statusCode: 503, -// message: -// "Course data is not available, please contact the website owner.", -// }); -// if (!colleges) -// throw createError({ -// statusCode: 503, -// message: -// "College data is not available, please contact the website owner.", -// }); -// if (!departments) -// throw createError({ -// statusCode: 503, -// message: -// "Departments data is not available, please contact the website owner.", -// }); -// const t1 = new Colleges(colleges); -// const t2 = new Departments(departments); -// return new AppCache(new Courses(courses, t1, t2), t1, t2); -// }; diff --git a/apps/frontend/pages/courses/[id].vue b/apps/frontend/pages/courses/[id].vue index f7ee8a52..35290f01 100644 --- a/apps/frontend/pages/courses/[id].vue +++ b/apps/frontend/pages/courses/[id].vue @@ -119,14 +119,11 @@ if (!t) statusMessage: `Page Not Found: ${route.path}`, }); const course = ref(t); -const { data: courseFeedbackRes } = await useFetch< - APIResponse ->( +const courseFeedbackUrl = computed( () => `${config.public.apiBaseUrl}/course-feedbacks/${course.value.classNo}`, - { - key: `${config.public.apiBaseUrl}/course-feedbacks/${course.value.classNo}`, - }, ); +const { data: courseFeedbackRes } = + await useFetch>(courseFeedbackUrl); if (!courseFeedbackRes.value || !courseFeedbackRes.value.data) throw createError({ statusCode: 503,