From e66b4ffa698a11eb2b6e8ee2b353c75a90336aae Mon Sep 17 00:00:00 2001 From: Kenny Date: Fri, 21 Dec 2018 14:02:40 -0500 Subject: [PATCH] Readability changes to async/await page Some of the flow in this page is a bit confusing - I think the changes I have made make it easier to read. --- 6-async/05-async-await/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/6-async/05-async-await/article.md b/6-async/05-async-await/article.md index dfa42978..5989fd73 100644 --- a/6-async/05-async-await/article.md +++ b/6-async/05-async-await/article.md @@ -83,12 +83,12 @@ function f() { } ``` -We can get such error in case if we forget to put `async` before a function. As said, `await` only works inside `async function`. +We will get this error if we do not put `async` before a function. As said, `await` only works inside an `async function`. ```` -Let's take `showAvatar()` example from the chapter and rewrite it using `async/await`: +Let's take the `showAvatar()` example from the chapter and rewrite it using `async/await`: -1. We'll need to replace `.then` calls by `await`. +1. We'll need to replace `.then` calls with `await`. 2. Also we should make the function `async` for them to work. ```js run @@ -122,7 +122,7 @@ showAvatar(); Pretty clean and easy to read, right? Much better than before. ````smart header="`await` won't work in the top-level code" -People who are just starting to use `await` tend to forget that, but we can't write `await` in the top-level code. That wouldn't work: +People who are just starting to use `await` tend to forget the fact that we can't use `await` in top-level code. For example, this will not work: ```js run // syntax error in top-level code