I have the following code in JavaScript:
for (var i = 0; i< uuids.length; i++){
var attr = uuids[i]
var uuid = attr["uuid"];
console.log("uuid is: " + uuid)
multiClient.hget(var1, var2, function(err, res1){
console.log("uuid INSIDE hget is: " + uuid)
}
}
hget
is an async method. Here are the prints of this function:
"uuid is: 1"
"uuid is: 2"
"uuid INSIDE hget is: 2"
"uuid INSIDE hget is: 2"
I wish to save the context of the uuid inside the hget function, so I will get:
"uuid is: 1"
"uuid is: 2"
"uuid INSIDE hget is: 1" (where all the context before the loop has saved for this uuid)
"uuid INSIDE hget is: 2" (where all the context before the loop has saved for this uuid)
How can I do that?