From d47e3f0d6d4c7fbdca6c60d0d40e0116918db839 Mon Sep 17 00:00:00 2001 From: yoon Date: Mon, 10 Feb 2025 16:06:22 +0900 Subject: [PATCH] =?UTF-8?q?yearCategory,=20cateList=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/commonApi.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/common/commonApi.js b/src/common/commonApi.js index 66cf53b..f7098e0 100644 --- a/src/common/commonApi.js +++ b/src/common/commonApi.js @@ -12,27 +12,28 @@ const commonApi = () => { const colorList = ref([]); const mbtiList = ref([]); const pwhintList = ref([]); + const yearCategory = ref([]); + const cateList = ref([]); + + const CommonCode = async (path, endpoint, targetList) => { + + const response = await $api.get(`${path}/${endpoint}`); + targetList.value = response.data.data.map(item => ({ + label: item.CMNCODNAM, + value: item.CMNCODVAL, + })); - const CommonCode = async (endpoint, targetList) => { - try { - const response = await $api.get(`/user/${endpoint}`); - targetList.value = response.data.data.map(item => ({ - label: item.CMNCODNAM, - value: item.CMNCODVAL - })); - } catch (error) { - console.error(`Error fetching ${endpoint}:`, error); - targetList.value = []; - } }; onMounted(async () => { - await CommonCode("color", colorList); - await CommonCode("mbti", mbtiList); - await CommonCode("pwhint", pwhintList); + await CommonCode("user", "color", colorList); + await CommonCode("user", "mbti", mbtiList); + await CommonCode("user", "pwhint", pwhintList); + await CommonCode("project", "yearCategory", yearCategory); + await CommonCode("worddict", "getWordCategory", cateList); }); - return { colorList, mbtiList, pwhintList }; + return { colorList, mbtiList, pwhintList, yearCategory, cateList }; }; export default commonApi;