To use the async lib – async.foreach with object with Node.js, we call forEach with a callback for each item.
For instance, we write
async.forEach(
Object.keys(dataObj),
(item, callback) => {
console.log(item);
callback();
},
(err) => {
console.log("iterating done");
}
);
to call forEach with a callback with the callback parameter that we call in the callback.
The callback in the 2nd argument is called when the async process is done.