add promise queue

This commit is contained in:
Ilya Kantor 2019-03-06 23:27:31 +03:00
parent 1373f6158c
commit 16cfa3037b
27 changed files with 160 additions and 36 deletions

View file

@ -0,0 +1,20 @@
# Rewrite using async/await
Rewrite the one of examples from the chapter <info:promise-chaining> using `async/await` instead of `.then/catch`:
```js run
function loadJson(url) {
return fetch(url)
.then(response => {
if (response.status == 200) {
return response.json();
} else {
throw new Error(response.status);
}
})
}
loadJson('no-such-user.json') // (3)
.catch(alert); // Error: 404
```