How to query all features from a map service using the exceededTransferLimit parameter?

Discussion created by Eletrosul on Nov 16, 2017

As you can see here : ArcGIS REST API 


Near 10.3 they included a new parameters so that you can work with query limits, for example you put a limit on your server of only 1000 records per query and you have 3000 records, you'll have to chain 3 requests.


But how? How can I make asynchronous calls that in a loop using dojo? How can I iterate them in a way that I can return all features


Synchronous mockup :


var query_results = [];var limit_hit = true; #While this is true means that the query hit the record limitvar start_from = 0; #Pagination parameterwhile (limit_hit) {    Server.Query(params={start_from : start_from}, callback=function(result){        limit_hit = result.limit_hit;        start_from = result.results.length;        query_result.push(result.results);    }}