@hollanditkzn

Как переписать все в koa?

Использую данную модуль passport-local-mongoose? но я использую koa и у меня постоянно пишет ошибку
(node:5384) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'request' of null
(node:5384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js p
rocess with a non-zero exit code.

Не пойму как переписать его
router.post('/registration', async (ctx) => {
    try {
        await User.register(new User({username: ctx.request.body.username}), ctx.request.body.password, (ctx) => {
                passport.authenticate('local') (ctx, () =>  {
                    ctx.redirect('/');
                });
            });
    } catch(err) {
        await ctx.render('registration', {message: err.message});
    }
});

Думаю что в этом коде где-то ошибка
  • Вопрос задан
  • 96 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы