인프런 커뮤니티 질문&답변
commentForm id 관련
작성
·
173
0
const onSubmitComment = useCallback(() => {
dispatch(
addCommentRequest({ content: commentText, postId: post.id, userId: id })
);
}, [commentText, post.id, id]);
const commnet = await Comment.create({
content: req.body.content,
PostId: req.params.postId,
UserId: req.user.id,
});
프론트에서 user.id를 redux에서 받아서 백엔드로 보내주는데 백엔드에서는 세션을 통해서 받은 userid를 사용하는데요.
프론트에서 그럼 user id를 굳이 보내지 않고 정의도 하지 않아도 괜찮겠죠? 따로 쓰이는 부분이 없는데 보내지고 있어 여쭤봅니다.




