-
Notifications
You must be signed in to change notification settings - Fork 0
/
day29.html
41 lines (36 loc) · 958 Bytes
/
day29.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
<!-- Chaining of Promises -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chaining Of Promises</title>
</head>
<body>
<h1>Chaining of Promises</h1>
<!-- Javasrcipt -->
<script>
let p1 = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Resolve after 2 sec");
resolve(26);
}, 2000);
});
p1.then((value) => {
console.log(value);
let p2 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve("promise 2");
}, 2000);
});
return p2;
}).then((value) => {
console.log("We are Done");
console.log(value);
return 2;
}).then((value)=>{
console.log("Done sir with resolve value of : ",value);
})
</script>
</body>
</html>