I have a question which might be silly. Correct me if I'm wrong.
I'm gettin 1 000 results from REST endpoint. However the results are tokenized and split into 100 element arrays. After I process 100 elements I need a callback to get next 100.
Below is my code for running through array
async.eachSeries(body.hits.hits, function(hit, loopHit) {
check_order(hit, loopHit);
}, function done() {
// get next array
});
The reason reason I do async here is because I need to know when I complete all 100 results (function done).
The result is - I need to run all 100 elements one by one (in check_order I connect to different REST point and wait for callback there), and I would like to run on all of them simultaneously, and once the last is completed I would like to get next array from first endpoint.
Any ideas?
Your callback is missing in the async:
async.eachSeries(body.hits.hits, function(hit, loopHit) {
check_order(hit);
loopHit();
}, function done() {
// get next array
});
And also you are giving the callback loopHit in the checkHit function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.