39 lines
994 B
JavaScript
39 lines
994 B
JavaScript
/*
|
|
작성자 : 박지윤
|
|
작성일 : 2025-02-04
|
|
수정자 :
|
|
수정일 :
|
|
설명 : 공통 api
|
|
*/
|
|
import { ref, onMounted } from "vue";
|
|
import $api from '@api';
|
|
|
|
const commonApi = () => {
|
|
const colorList = ref([]);
|
|
const mbtiList = ref([]);
|
|
const pwhintList = ref([]);
|
|
|
|
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);
|
|
});
|
|
|
|
return { colorList, mbtiList, pwhintList };
|
|
};
|
|
|
|
export default commonApi;
|