대댓글
This commit is contained in:
parent
fdb2d81e53
commit
a21bf8f6a1
@ -266,15 +266,15 @@ const fetchComments = async (page = 1) => {
|
||||
});
|
||||
|
||||
// 대댓글
|
||||
const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, {
|
||||
params: {
|
||||
LOCCMTPNT: 120
|
||||
}
|
||||
});
|
||||
// const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, {
|
||||
// params: {
|
||||
// LOCCMTPNT: 120
|
||||
// }
|
||||
// });
|
||||
|
||||
console.log(replyResponse.data)
|
||||
// console.log(replyResponse.data)
|
||||
|
||||
comments.value = response.data.data.list.map(comment => ({
|
||||
const commentsList = response.data.data.list.map(comment => ({
|
||||
commentId: comment.LOCCMTSEQ, // 댓글 ID
|
||||
boardId: comment.LOCBRDSEQ,
|
||||
parentId: comment.LOCCMTPNT, // 부모 ID
|
||||
@ -289,6 +289,25 @@ const fetchComments = async (page = 1) => {
|
||||
children: [] // 대댓글을 담을 배열
|
||||
}));
|
||||
|
||||
for (const comment of commentsList) {
|
||||
// 대댓글 조회
|
||||
const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, {
|
||||
params: {
|
||||
LOCCMTPNT: comment.parentId // 부모 댓글의 ID를 사용
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`댓글 ${comment.parentId}의 대댓글:`, replyResponse.data);
|
||||
|
||||
// 대댓글이 있다면 children 배열에 추가할 수 있습니다
|
||||
if (replyResponse.data.data) {
|
||||
comment.children = replyResponse.data.data;
|
||||
}
|
||||
}
|
||||
|
||||
// 최종적으로 댓글 목록 업데이트
|
||||
comments.value = commentsList;
|
||||
|
||||
pagination.value = {
|
||||
...pagination.value,
|
||||
currentPage: response.data.data.pageNum, // 현재 페이지 번호
|
||||
|
||||
Loading…
Reference in New Issue
Block a user