Promises, async functions, and Express router functions

Before we get into developing our application, we must take a deeper look at a pair of new ES-2015/2016/2017 features that collectively revolutionize JavaScript programming:  The Promise class and async functions. Both are used for deferred and asynchronous computation and can make intensely nested callback functions a thing of the past:

  • A Promise represents an operation that hasn't completed yet but is expected to be completed in the future. We've seen Promises in use. The .then or .catch functions are invoked when the promised result (or error) is available. 
  • Generator functions are a new kind of function that can be paused and resumed, and can return results from the middle of the ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.