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;