recursion - Node.js recursive function with super agent -


i'm developing simple function that, making use of superagent module, query api service retrieve information splitted in several pages.

as finish each call have push information array , retrieved last page, start working on array.

using normal way sure i'll have problem due async-ness, need callback or event emitter rid of this.

atm used code, doesn't work:

function getpage(page){   pages = new array()   superagent.get('http://localhost/api.json')   .end(function(r){    if(r[r.length-1] == 'value')     getpage(page++)    else     pages.push(r);   ); } 

take @ async.js, it's useful library can this.


Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -