我试图在mongoose save回调中更新快速会话数据。如何从第4行内访问(和更新)会话数据?
app.get('/', function(request, response){
var model = new Model(somedata);
request.session.ok = "ok";
model.save(function (err, data) {
request.session.ok = "won't save";
});
});
app.get('/path', function(request, response) {
console.log(request.session.ok);
// returns 'ok'
});
答案 0 :(得分:2)
您需要发送某种回复。例如:
app.get('/', function(request, response){
var model = new Model(somedata);
request.session.ok = "ok";
model.save(function (err, data) {
request.session.ok = "won't save";
response.send(200);
});
});