asyncprovides two important parameters to your function iterator: a itemand a callback. The first gives you the actual data element from the array, and the second gives you a function indicating the end of the actual method. A final callback (one that has a log ("ok")) is called when each iterator call points to its own callback.
So your code should look something like this:
async.each(spiders, function(item, callback) {
console.log('spider: ' + item);
callback(null);
}, function(err) {
if (err) {
return console.log(err);
}
console.log('ok');
});
The parameter nullmeans that there is no error.
, , , .