I am trying to get multiple values ββfrom redis, combine them and eventually send. But I just can't get these promises to work.
These are simple get functions from redis
client.get('user:1:id',function(err,data){ // here I have data which contains user ID }); client.get('user:1:username',function(err,data){ // here I have data which contains username });
Now I want to get the ID and username and send them, but I don't know how to do this. I manage to get it to work with callbacks, but this is a very dirty result, so I tried to wrap anonymous functions in Q.fcall even after the .then call, which looks something like this.
client.get('user:1:id',Q.fcall(function(err,data){ return data; }).then(function(val) { // do something }));
but it gives me an error because too many arguments have been passed, and I'm not even sure if this will help me, even if it works.
Giedrius
source share