Skip to content

Commit 5280843

Browse files
committed
Section 18: A Quick Overview of Async Functions
1 parent bf22686 commit 5280843

5 files changed

Lines changed: 46 additions & 208 deletions

File tree

17-Making-HTTP-Requests/README copy.md

Lines changed: 0 additions & 208 deletions
This file was deleted.

18-Async-Await-JS-Magic/01/app.css

Whitespace-only changes.

18-Async-Await-JS-Magic/01/app.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ******************************
2+
// A Quick Overview of Async Functions ******************************
3+
// Example 1
4+
5+
console.log('A Quick Overview of Async Functions')
6+
7+
// function getData() {
8+
// const data = axios.get('https://swapi.dev/api/planets/')
9+
// console.log(data)
10+
// }
11+
// getData()
12+
13+
// Example 2
14+
function getData() {
15+
const data = axios.get('https://swapi.dev/api/planets/').then((data) => {
16+
console.log(data)
17+
})
18+
console.log(data)
19+
}
20+
getData()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="stylesheet" href="app.css" />
8+
<title>JavaScript</title>
9+
</head>
10+
<body>
11+
<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script>
12+
<script src="app.js"></script>
13+
</body>
14+
</html>

18-Async-Await-JS-Magic/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## 18-Async-Await-JS-Magic
2+
3+
## 1. A Quick Overview of Async Functions
4+
5+
#### ASYNC FUNCTIONS
6+
7+
Async functions depend extremely heavily on promises. Async functions are just a nice syntactic sugar for promises. It's a nice, clean, easy syntax to work with promises, but you still have to understand promises.
8+
9+
#### 2 PIECES
10+
11+
- ASYNC
12+
- AWAIT

0 commit comments

Comments
 (0)