Node.js async.js

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • 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?