Skip to content

Instantly share code, notes, and snippets.



Last active Jan 28, 2017
What would you like to do?
Re-writing mariusa's example from
a: function(callback) {
fs.readFile('a.html', 'utf8', function(err, a) {
if (err) callback(err);
console.log('read a');
callback(null, a);
b: function(callback) {
fs.readFile('b.html', 'utf8', function(err, b) {
if (err) callback(err);
console.log('read b');
callback(null, b);
}, function (err, results) {
console.log('a:' + results.a);
console.log('b:' + results.b);

This comment has been minimized.

Copy link

@cvrabie cvrabie commented Jan 28, 2017

You know this is incorrect right? The callback would get called twice in the parallel functions. Either place the second callback in an else block or use if (err) **return** callback(err);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment