I’m trying to get a value from a Redis database. Code:
callback(null, 'Please enter PIN.');
read = db.get(cmd + ':pin');
console.log(read);
n = db.get(cmd + ':name');
waitingType = 'pin';
wait = 1;
However, when I console.log(read) I get true. Why don’t I get the value of db.get(cmd + ':pin')?
db.get is asynchronous, so the db call isn’t done yet when your program reaches the console.log( read )