After the two async functions are completed, simply pass the final value to a new function and do some work with it.
var redis = require('redis');
var client = redis.createClient(port, 'anyhost');
client.exists(obj.empId, function(err, reply) {
if (reply == 0) {
console.log('indb call');
db.one('SELECT * FROM iuidtest WHERE empid = $1', [obj.empId])
.then(iuidtest => {
console.log(iuidtest.iuid);
doSomethingWith(iuidtest.empid);
})
}
});
const doSomethingWith = empid => {
console.log( "empid = ", empid );
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…