So lets say fruits is an array containing 4 items What I expected was that the code below would print fruit with a 4 second delay between each fruit.
var fruits = ['blueberries', 'strawberries', 'mango', 'peaches'];
async.forEach(fruits, functions(fruit, next) {
setTimeout(function() {
console.log(fruit);
}, 4000);
})
The actual behaviour is that it waits 4 seconds, and then prints the entire list. :\ Does anybody know how to achieve my expected behaviour?
async.series
, and you need to actually call the callback. – Indwell