From 1ca9bc1758d3184259de7b32127aacd98350118d Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Sun, 12 Apr 2026 21:55:00 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20plans=20store=E4=BD=BF=E7=94=A8api()?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84requestJS?= =?UTF-8?q?ON?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/stores/plans.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/stores/plans.js b/frontend/src/stores/plans.js index 5d0f46b..8a7b9fa 100644 --- a/frontend/src/stores/plans.js +++ b/frontend/src/stores/plans.js @@ -1,6 +1,6 @@ import { defineStore } from 'pinia' import { ref, computed } from 'vue' -import { requestJSON, api } from '../composables/useApi' +import { api } from '../composables/useApi' export const usePlansStore = defineStore('plans', () => { const plans = ref([]) @@ -11,11 +11,13 @@ export const usePlansStore = defineStore('plans', () => { const pendingPlans = computed(() => plans.value.filter(p => p.status === 'pending')) async function loadPlans() { - plans.value = await requestJSON('/api/oil-plans') + const res = await api('/api/oil-plans') + if (res.ok) plans.value = await res.json() } async function loadTeachers() { - teachers.value = await requestJSON('/api/teachers') + const res = await api('/api/teachers') + if (res.ok) teachers.value = await res.json() } async function createPlan(healthDesc, teacherId) { @@ -50,7 +52,8 @@ export const usePlansStore = defineStore('plans', () => { } async function loadShoppingList(planId) { - shoppingList.value = await requestJSON(`/api/oil-plans/${planId}/shopping-list`) + const res = await api(`/api/oil-plans/${planId}/shopping-list`) + if (res.ok) shoppingList.value = await res.json() } return {