Code Comparison

See the difference at a glance.

Before
// Nested callbacks
getUser(id, function(user) {
  getPosts(user, function(posts) {
    getComments(posts, function(comments) {
      render(comments);
    });
  });
});
After
// Async/await
const user = await getUser(id);
const posts = await getPosts(user);
const comments = await getComments(posts);
render(comments);