Node.js async.js

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


  • Each callback must be written with this syntax:

  • function callback(err, result [, arg1[, ...]])

  • This way, you are forced to return the error first, and can't ignore handling them later on. null is the convention in absence of errors

  • callback(null, myResult);

  • Your callbacks can contain more arguments than err and result, but it's useful only for a specific set of functions (waterfall, seq, ...)

  • callback(null, myResult, myCustomArgument);

  • And, of course, send errors. You must do it, and handle errors (or at least log them).

  • callback(err);

Got any Node.js Question?