inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

강수윤님의 게시글

강수윤 강수윤

@gangsuyun67024

수강평 작성수
-
평균평점
-

게시글 3

질문&답변

9장 nodebird관련질문

그럼 어떤식으로 넌적스에 변수를 넘겨 주어야 하나요? res . locals . likesList = req . user ? Post . Likes . map ( l => l . id ) : []; 이런식으로 넘겨주려고 해도 map은 없는 메서드라는 에러가 뜹니다. 이런 상황에서 req.user ? Post.Likes.map(l => l.id) : []; 이부분을 도저히 어떻게 짜야할지 모르겠습니다 시퀄라이즈 부분에서 참조로 만든 테이블을 어떻게 가져오나요??

좋아요수
0
댓글수
6
조회수
374

질문&답변

9장 nodebird관련질문

귀찮게 해드려서 죄송합니다! ㅠㅠ 넌적스 코드를 이렇게 바꾸고 {% if user and not (req.twits and likesList.include(req.user.id)) %} button class = "like" > 좋아요 button > {% elif user and (req.twits and likesList.include(req.user.id)) %} button class = "unlike" > 좋아요 취소 button > {% endif %} page.js에 router . use (( req , res , next ) => { // res.locals.like = req.user && req.twit && twit.Liker.map(l => l.id).include(req.user.id); res . locals . user = req . user ; res . locals . followerCount = req . user ? req . user . Followers . length : 0 ; res . locals . followingCount = req . user ? req . user . Followings . length : 0 ; res . locals . followerIdList = req . user ? req . user . Followings . map ( f => f . id ) : []; res . locals . likesList = req . user ? req . twit . Likers . map ( l => l . id ) : []; next (); }); 이렇게 코드를 추가했습니다 이때 res . locals . likesList = req . user ? req . twit . Liker . map ( l => l . id ) : []; 이 부분에서 Liker나 Likers등 어떤걸 넣어도 Cannot read property 'Liker' of undefined 라는 에러가 뜹니다 ㅠㅠ 이부분을 어떻게 받아와야 할까요??

좋아요수
0
댓글수
6
조회수
374

질문&답변

9장 nodebird관련질문

바꾸면 {% if user and not req.user and req.twit and twit.Liker.map(l => l.id).include(req.user.id) %} button class = "like" > 좋아요 button > {% elif user and req.user and req.twit and twit.Liker.map(l => l.id).include(req.user.id) %} button class = "unlike" > 좋아요 취소 button > {% endif %} 이런식으로 되는데 넌적스에서는 화살표 함수가 먹지 않아서 어떻게 바꿔야 할지 도저히 모르겠습니다 ㅠㅠ

좋아요수
0
댓글수
6
조회수
374