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
'TIL' 카테고리의 다른 글
114. 브라우저 렌더링 TIL 23.01.17 (0) | 2023.01.17 |
---|---|
113. HTTP 통신흐름 TIL 23.01.16 (1) | 2023.01.16 |
111. null 병합연산자 란? TIL 23.01.11 (0) | 2023.01.12 |
110. React Hook 이란? TIL 23.01.11 (0) | 2023.01.11 |
109. onKeyPress 사용하지 않음 TIL 23.01.09 (0) | 2023.01.09 |
댓글