인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

이규열's profile image
이규열

asked

[Renewed] Node.js Textbook - From Basics to Project Practice

Implementing following and followers

로그아웃 오류

Written on

·

206

0

req#logout requires a callback function

로그아웃을 하는 프론트에 이런 에러메시지가 나옵니다

router.get('/logout', isLoggedIn, (req, res) => {
    req.logout();
    req.session.destroy();
    res.redirect('/');
});

로그아웃 라우터는 이렇게 작성을했는데 콜백함수가 없다는 말이 무슨뜻인지 잘 모르겠습니다

mongodbmysqlnodejsSequelize

Answer 3

0

이규열님의 프로필 이미지
이규열
Questioner

router.get('/logout', isLoggedIn, async(req, res, next) => {
    req.logout((err) => {
        req.session.destroy();
        if (err) {
            res.redirect("/");
        } else {

            res.redirect("/");
        }
    });
});

링크 참고해서 만들었는데 링크에 댓글 다신분은 위에 코드 처럼 인자에 next를 넣어놓으셨던데 함수에 next를 반환하는것도 아닌데 next를 인자로 가질 필요가 있나요?

zerocho님의 프로필 이미지
zerocho
Instructor

안 쓰는 매개변수이므로 적지 않아도 됩니다.

0

zerocho님의 프로필 이미지
zerocho
Instructor

강좌 공지사항 참고하세요

이규열's profile image
이규열

asked

Ask a question