Answer the question
In order to leave comments, you need to log in
What does such a code mean?
I can't figure out what it means res.redirect
? and even more incomprehensible what he does in conjunction with return
?
exports.getLogin = (req, res) => {
if (req.user) {
return res.redirect('/'); //
}
res.render('account/login', {
title: 'Login'
});
app.get('/login', userController.getLogin);
Answer the question
In order to leave comments, you need to log in
Have you tried reading the documentation?
expressjs.com/en/api.html#res.redirect
And in combination with return it does the same thing as
res.redirect('/');
return;
return is needed here to exit the getLogin function before rendering the login page, provided that the user is logged in.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question