async.each not working properly

Created on 6 Jul 2016  路  1Comment  路  Source: caolan/async

What version of async are you using?
^2.0.0-rc.6

Which environment did the issue occur in (Node version/browser version)
Node v5.10.0 & NPM 3.8.3

What did you do? Please include a minimal reproducable case illustrating issue.

var async = require('async');

async.each(['foo', 'bar', 'duh'], function(data, callback) {

    console.log('starting.. '+data);
    setTimeout(function() {
        console.log('started '+data);
        callback();
    }, 5000);

}, function(err) {

    console.log('all started');
});

What did you expect to happen?

starting.. foo
started foo
starting.. bar
started bar
starting.. duh
started duh
all started

What was the actual result?

starting.. foo
starting.. bar
starting.. duh
started foo
started bar
started duh
all started
question

Most helpful comment

You want eachSeries

>All comments

You want eachSeries

Was this page helpful?
0 / 5 - 0 ratings