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

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -