lemahdois
lemahdois

Reputation: 73

conditional breakpoint on node.js

I am tryning to retrieve facebook feeds using this function

function getFeeds(url,page,id,count){

graph.get(url, function(err, res) {


   if(!err){
     res.data.forEach(function(item) {
               id.push(item);
            });
     if ( res.paging.next && count>0) setTimeout(getFeeds(res.paging.next,page,id,count-1),100)
      else {
             id.forEach(function(item){
             console.log(item);
           })
    };                  
   }
});
};

However, this function returns this error

/Users/adelessafi/fb/getfeeds.js:20
     if (res.paging.next  && count>0) setTimeout(getFeeds(res.paging.next,page,id,count-1),100)
                   ^

TypeError: Cannot read property 'next' of undefined
    at Graph.callback (/Users/adelessafi/fb/getfeeds.js:20:20)
    at Graph.end (/Users/adelessafi/fb/node_modules/fbgraph/lib/graph.js:170:8)

I want to stop the execution of my script tjust before the error. Note that my script make a huge number of calls so I have to make a conditional breakpoint.

Thank you in advance for any entry

Upvotes: 1

Views: 736

Answers (1)

Strelok
Strelok

Reputation: 51431

You can simulate it by putting a debugger; statement in an if.

if (condition) {
  debugger;
}

Just make sure your debugger is attached.

Upvotes: 1

Related Questions