-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync.js
More file actions
50 lines (43 loc) · 760 Bytes
/
async.js
File metadata and controls
50 lines (43 loc) · 760 Bytes
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
46
47
48
49
50
// Promise
function a(){
return new Promise(function (resolve){
setTimeout(function(){
console.log('A')
resolve("B 실행~")
}, 1000)
})
}
function b(res){
return new Promise(function(resolve){
setTimeout(function(){
console.log('B')
console.log(res)
resolve()
}, 1000)
})
}
function c(res){
console.log('C')
}
a()
.then(() => b())
.then(c)
// 예외 처리
const url = 'https://www.omdbapi.com/?i=tt3896198&apikey=7035c60c'
axios(url)
.then(res => {
console.log(res)
})
.catch(err => {
console.log('error!!!!!!!', err)
})
.finally(() => {
console.log('완료')
})
// async/ await
async function template(){
await axios.get(url)
await a()
await b()
await c()
}