You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/11-async/08-async-await/01-rewrite-async/solution.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
2
-
The notes are below the code:
2
+
Les notes sont en dessous du code:
3
3
4
4
```js run
5
5
asyncfunctionloadJson(url) { // (1)
@@ -19,15 +19,15 @@ loadJson('no-such-user.json')
19
19
20
20
Notes:
21
21
22
-
1.The function`loadJson`becomes`async`.
23
-
2.All `.then`inside are replaced with`await`.
24
-
3.We can`return response.json()`instead of awaiting for it, like this:
22
+
1.La fonction`loadJson`devient`async`.
23
+
2.Tous les `.then`intérieurs sont remplacés par`await`..
24
+
3.Nous pouvons`return response.json()`au lieu de l'attendre, comme ceci:
25
25
26
26
```js
27
27
if (response.status==200) {
28
28
returnresponse.json(); // (3)
29
29
}
30
30
```
31
31
32
-
Then the outer code would have to `await`for that promise to resolve. In our case it doesn't matter.
33
-
4. The error thrown from `loadJson` is handled by `.catch`. We can't use `await loadJson(…)`there, because we're not in an `async` function.
32
+
Ensuite, le code externe devra "attendre" la résolution de cette promesse. Dans notre cas, cela n'a pas d'importance.
33
+
4.L'erreur émise par `loadJson` est gérée par `.catch`. Nous ne pouvons pas utiliser `await loadJson(...)` ici, car nous ne sommes pas dans une fonction `async`..
0 commit comments