Using the await function

At this point, we have only used half of the feature. We've used the async part, which alone is not particularly useful. It gets really useful when we combine it with await, so let's go ahead and start taking a look at that. 

The await function is going to allow us to introduce the other functions back into play, getGrades and getUser. We're just going to go ahead and use await, and then we'll talk about exactly what's happening. So, for the moment, bear with me and just type out this line: const user = and we're going to set it equal to the await keyword. We'll talk about this in just a second; we're going to call getUser and we're going to pass in the userId. So let's start breaking this line down:

 const getStatusAlt ...

Get Advanced Node.js Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.