I use this code to get the user's ID saved in the key user:their_email_id.
redis.get("user:" + email, function(err, reply) {
if (reply != null) {
id = reply;
console.log(reply);
}
});
This gives me the user's ID in the id
variable.
Now I use this ID to query the user's hash:
redis.hgetall("user:" + id, function (err, reply) {
console.log(reply);
});
Here I get the reply as null. The reason is instead of the key becoming something like:
user:0
I'm getting this:
user:undefined
Now I know that it successfully returns the ID, and everything is working, except that when concatenating the ID with the "user:" string, it fails.
I also tried using id.toString(), but Express shows method not found. Why could this be happening? Do I have to require some library?
And how do I solve this issue?
Thanks