-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpromise_API.html
More file actions
40 lines (37 loc) · 1.12 KB
/
Copy pathpromise_API.html
File metadata and controls
40 lines (37 loc) · 1.12 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
//create an Promise Object
const myPromise = new Promise((resolve,reject)=>{
let isValid = true;//boolean
if(isValid){
resolve("Block gets executed");
resolve("Done");
}
else reject("Error Occured");
});
//calling the created Promise.
myPromise
.then((str)=>{
console.log(str);
})
.then((str2)=>{
console.log(str2);
})
.catch((error)=>{
console.log(error);
})
.finally(()=>{
console.log("Promise is working");
});
//Promise is an Unicast Object .
//it can have only one value to be send at the same time.
</script>
</body>
</html>