samedi 7 mars 2015

NodeJS - How to obtain the result to be used in another scope

I come from PHP and I'm kind of new to NodeJS.


I have a middleware that is doing some sort of session check:



app.io.use(function(socket, next) {

var redisClient = redis.createClient();

redisClient.get('sess:1234', function(err, reply) {

});
}


What I would like to do is to get the reply coming from redis query and use it in the middleware scope to check for some conditions, to assert an error or move along to the next step.


How this can be achieve?


Thanks.


Aucun commentaire:

Enregistrer un commentaire