본문 바로가기
TIL

112. Til 23.01.13

by 새싹_v 2023. 1. 13.
728x90


 

트러블 슈팅

오늘은 Firebase를 통해서 백엔드를 구현하고 s3를 통해 배포까지 해봤다.
spa로 프론트를 만드는 와중에 commentlist를 불러오지 못하는 오류가 있었다.
아래에 문제가되는 코드를 확인해 보자.

 

 

오류: spa로 프론트를 만드는 와중에 commentlist를 불러오지 못하는 오류가 있었다.

//router.js

export const handleLocation = async () =>{
    let path = window.location.hash.replace("#","");
    const pathName = window.location.pathname;

    if (path === "fanLog"){
        document.getElementById("nickname").textContent = authService.currentUser.displayName ?? "닉네임 없음";
        document.getElementById("profileImg").src = authService.currentUser.photoURL ?? "../assets/blankProfile.webp";
    }
};

위 코드처럼 작성하면 아래 사진처럼 나온다.

응원 남기기를 눌러야 commentlist가 나타난다. 정상적으로 나오려면 페이지가 나오자마자
commentlist가 나와야 한다. 

 

 

해결: getCommentList(); 추가

//router.js

export const handleLocation = async () =>{
    let path = window.location.hash.replace("#","");
    const pathName = window.location.pathname;

    if (path === "fanLog"){
        document.getElementById("nickname").textContent = authService.currentUser.displayName ?? "닉네임을 설정해주세요";
        document.getElementById("profileImg").src = authService.currentUser.photoURL ?? "../assets/blankProfile.webp";
    	getCommentList();
    }
};
commentlist를 불러오는 함수를 조건문안에 넣어줬더닌 정상적으로 commentlist가 나옴
 

 

728x90

댓글