Can't wrap my mind around node.js javascript callback nest function -


i check around web , still cant resolve issue.

in node.js, want set interval fetching redis data. cannot make work.

here code:

setinterval(function(){     redis.hget('quote','quote1', function (err, res) {         console.log('test');         console.log(res);     }); }, 1000); 

edited: if use redis snippet without setinterval, works fine. when wrapped inside setinterval function, doesn't work. redis client nodejs_redis. checked err returns null.

please refer snippet , result below

setinterval(function(){    console.log(' line a');    redis.hget('quote','quote1', function (err, res) {       console.log('line b');       console.log(res);    }); }, 1000); 

line log normal. line b , res wont log no matter what.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -