공통 api
This commit is contained in:
parent
9ee69e6730
commit
b841029bbe
38
src/common/commonApi.js
Normal file
38
src/common/commonApi.js
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
작성자 : 박지윤
|
||||
작성일 : 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;
|
||||
Loading…
Reference in New Issue
Block a user