How do you pass an argument to the iterator function for async.each?
You can create a partial function using bind
:
async.each(myArray, urlToS3.bind(null, 'image'), ...);
The argument 'image'
would be passed as the first argument to your function (the rest of the arguments would be the arguments passed by async
), so it would look like this:
function urlToS3(fileType, url2fetch, cb) {
...
}