Sunday, 14 May 2017

How to execute code sequentially inside asynchronous function in node js

every(60, 'seconds', function() {
var cron_channel = [];
session
  .run('match (c:channel) where c.from="yt" return c')
  .then(function(result){
    result.records.forEach(function(record){
      cron_channel.push({
        title: record._fields[0].properties.channelid
      });
console.log(cron_channel); 
    });

console.log(cron_channel); 
});

when I execute this code than the above console.log prints the value but the below console.log prints undefined. help me how will I execute it complete session first and then console.log prints the value. I want the value outside the session. Thanks in Advance



via Prateek218

No comments:

Post a Comment