Skip to content

Commit e8f059a

Browse files
committed
updated async await dependencies
1 parent da08e8c commit e8f059a

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

14 Async await/00_start/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ $ npm start
5353
npm install --save-dev @babel/core
5454
npm install --save-dev @babel/plugin-transform-runtime
5555
npm install --save @babel/runtime
56+
npm install --save parcel
5657
```
5758

5859
* Create _.babelrc_ on _rootDir_
@@ -95,6 +96,8 @@ showBooks();
9596
### 2. Now we are going to transform this code into async / await style.
9697

9798
```diff
99+
+ import "regenerator-runtime/runtime";
100+
98101
-function showBooks() {
99102
+async function showBooks() {
100103
const url = 'http://localhost:8000/api/books/';
@@ -205,7 +208,7 @@ showBooks()
205208

206209
```javascript src/api/BookApiClient.js
207210
export class BookApiClient {
208-
async fetchUser() {
211+
async fetchBooks() {
209212
const url = 'http://localhost:8000/api/books/';
210213
const response = await fetch(url);
211214
return await response.json();

14 Async await/00_start/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
"author": "Jaime Salas",
1616
"license": "MIT",
1717
"devDependencies": {
18-
"babel-plugin-transform-runtime": "^6.23.0",
19-
"babel-runtime": "^6.26.0",
20-
"parcel": "^1.8.1"
18+
"@babel/core": "^7.8.4",
19+
"@babel/plugin-transform-runtime": "^7.8.3",
20+
"@babel/runtime": "^7.8.4",
21+
"parcel": "^1.12.4"
2122
}
2223
}

14 Async await/00_start/src/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "regenerator-runtime/runtime";
12
// async function showBooks() {
23
// const url = 'http://localhost:8000/api/books/';
34
// const response = await fetch(url);

14 Async await/01_errors/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ export async function showBooks(url) {
5353
+ return body;
5454
}
5555
```
56+
5657
* Automatically rejects the promise, because of 'throw Error'
58+
5759
* Now here we have two different scenarios:
60+
5861
```javascript
5962
const url = `http://localhost:8000/api/boos/`; // Wrong url. //
6063
const url2 = `http://localhost:8000/api/books/5
6164
```
65+
6266
* The first one no internal route it's handle by our code (no controller responds to that route). In this case there is not response error handle from
6367
6468
* In the second case, the response it's handle from our controller's code sending to us a 500.

0 commit comments

Comments
 (0)