node-async

Node.js - Using the async lib - async.foreach with object

混江龙づ霸主 提交于 2019-11-27 06:33:18
I am using the node async lib - https://github.com/caolan/async#forEach and would like to iterate through an object and print out its index key. Once complete I would like execute a callback. Here is what I have so far but the 'iterating done' is never seen: async.forEach(Object.keys(dataObj), function (err, callback){ console.log('*****'); }, function() { console.log('iterating done'); }); Why does the final function not get called? How can I print the object index key? The final function does not get called because async.forEach requires that you call the callback function for every element.

Node.js - Using the async lib - async.foreach with object

半腔热情 提交于 2019-11-26 12:03:40
问题 I am using the node async lib - https://github.com/caolan/async#forEach and would like to iterate through an object and print out its index key. Once complete I would like execute a callback. Here is what I have so far but the \'iterating done\' is never seen: async.forEach(Object.keys(dataObj), function (err, callback){ console.log(\'*****\'); }, function() { console.log(\'iterating done\'); }); Why does the final function not get called? How can I print the object index key? 回答1: The final