-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
45 lines (37 loc) · 986 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
const pr1 = new Promise(( resolve, reject ) => {
setTimeout(() => {
reject({name: 'Adriano', age: 28})
}, 2000)
})
// pr1
// .then(data => console.log(data), err => console.error(err))
pr1
.then(data => console.log(data))
.catch(err => console.error(err))
async function getPost() {
const pr2 = new Promise(( resolve, reject ) => {
setTimeout(() => {
resolve({name: 'Adriano', age: 28})
}, 1000)
})
try {
const resolve = await pr2;
console.log(resolve)
} catch (error) {
console.error(error)
}
}
// getPost();
</script>
</body>
</html>