diff --git a/src/views/board/BoardList.vue b/src/views/board/BoardList.vue index eda8118..55d0f0c 100644 --- a/src/views/board/BoardList.vue +++ b/src/views/board/BoardList.vue @@ -59,8 +59,8 @@ import WriteButton from '@c/button/WriteBtn.vue'; import axios from '@api'; // 데이터 초기화 -const list = ref([]); -const list2 = ref([]); +const generalList = ref([]); +const noticeList = ref([]); const searchText = ref(''); // 상세 페이지 이동 @@ -75,14 +75,14 @@ const search = (e) => { // 검색 결과 필터링(일반게시물) const filteredList = computed(() => - list.value.filter((item) => + generalList.value.filter((item) => item.title.toLowerCase().includes(searchText.value.toLowerCase()) ) ); // 검색 결과 필터링(공지사항) const filteredList2 = computed(() => - list2.value.filter((item) => + noticeList.value.filter((item) => item.title.toLowerCase().includes(searchText.value.toLowerCase()) ) ); @@ -115,7 +115,7 @@ const fetchPosts = async () => { const response = await axios.get("board/general"); if (response.data && response.data.data && Array.isArray(response.data.data.list)) { - list.value = response.data.data.list.map((post, index) => ({ + generalList.value = response.data.data.list.map((post, index) => ({ ...post, id: post.id || index, img: post.img || null, @@ -128,24 +128,18 @@ const fetchPosts = async () => { }; const fetchPosts2 = async () => { - try { - console.log('ㅁㄴㅇㅁㅇㅁ') - const response = await axios.get("board/notices"); - console.log(response) + const response = await axios.get("board/notices"); - if (response.data && response.data.data && Array.isArray(response.data.data)) { - list2.value = response.data.data.map((post, index) => ({ - ...post, - id: post.id || index, - img: post.img || null, - likes: post.likes || 0, - comments: post.comments || 0, - })); - } else { - console.error("데이터 오류:", response.data); - } - } catch (error) { - console.error("공지사항 데이터 로드 실패:", error); + if (response.data && response.data.data && Array.isArray(response.data.data)) { + noticeList.value = response.data.data.map((post, index) => ({ + ...post, + id: post.id || index, + img: post.img || null, + likes: post.likes || 0, + comments: post.comments || 0, + })); + } else { + console.error("데이터 오류:", response.data); } };