-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathes6_promise.html
42 lines (38 loc) · 978 Bytes
/
es6_promise.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function getInfo(type,url) {
return new Promise((resolve, reject) => {
let XHM=new XMLHttpRequest()
XHM.onreadystatechange=function (e) {
if (this.readyState !== 4) {
return;
}
if(XHM.status===200){
resolve(this.response)
}else {
reject(new Error(this.statusText))
}
};
XHM.open(type,url,true)
XHM.send()
})
}
const url='https://www.easy-mock.com/mock/5a769ac93c4ca20b4f1dd692/example_copy/list/:id#!method=get'
getInfo('get',url).then((data)=>{
console.log(data)
}).catch((e)=>{
console.log(e)
})
let [a,b,c]=[1,2,3]
console.log(a)
console.log(b)
console.log(c)
</script>
</body>
</html>