-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
Error: Unable to call `followerIdList["includes"]`, which is undefined or falsey
23.05.24 20:58 작성 조회수 435
1
로그인 후 포스팅 하나 작성하면 계속 에러가 발생합니다.
exports.renderMain = async (req, res, next) => {
try {
const posts = await Post.findAll({
include: {
model: User,
attributes: ['id', 'nick'],
},
order: [['createdAt', 'DESC']] // 최신순 정렬(작성일 기준 내림차순)
});
res.render('main', {
title: 'NodeBird',
twits: posts
});
} catch (error) {
console.error(error);
next(error);
}
};
renderMain 메서드에서 따로 follwerIdList를 보내지 않는 것 같은데
{% for twit in twits %}
<div class="twit">
<input type="hidden" value="{{twit.User.id}}" class="twit-user-id">
<input type="hidden" value="{{twit.id}}" class="twit-id">
<div class="twit-author">{{twit.User.nick}}</div>
{% if not followerIdList.includes(twit.User.id) and twit.User.id !== user.id %}
<button class="twit-follow">팔로우하기</button>
{% endif %}
<div class="twit-content">{{twit.content}}</div>
{% if twit.img %}
<div class="twit-img"><img src="{{twit.img}}" alt="섬네일"></div>
{% endif %}
</div>
{% endfor %}
followerIdList는 어디서 나온 어디서 나온건지 찾을 수가 없습니다..
답변을 작성해보세요.
1
답변 1