Used the session middleware in express,
There is no user in the object!
Req.session.user is assigned a value before redirection
This is the route
.png](/img/bVNmO9)
This is the render page. How did you get this user value? Why don't we need to assign a user value to the incoming object in render? How does it work? Why do some need it?
In the next page that this page jumps to, if no value is assigned, it will not be recognized.
exports.publish=function (req,res,next) {
return res.render('publish',{
key:'publish',
user:req.session.user
});
}
The poster’s question is just one question, callback assignment in node
The value of callback in node is different from the general callback. It cannot be understood as a general callback. The general callback is assigned a value. This is not an assignment, but a method. A value is directly assigned to User
analogous to
According to the above idea, if you don’t understand, ask me again.
User.newUserSave generates a value and assigns it to user