A real-world example

In this section, we're going to move on from our contrived example and we're going to look at an example using two real HTTP APIs. Before we do, it's important to note that arrow functions (=>) aren't the only functions that support async. I just happen to use an arrow function (=>). I could also use an ES5 function with the function keyword; this works as well:

const getStatusAlt = async function (userId) {  const user = await getUser(userId);  const grades = await getGrades(user.schoolId);  let average = 0;

I can save the file and I'm still going to get Jessica has 100% printing:

I could also async an ES6 object method, ...

Get Advanced Node.js Development 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.