File tree 2 files changed +65
-5
lines changed
2 files changed +65
-5
lines changed Original file line number Diff line number Diff line change 7
7
<!-- add js file -->
8
8
<!-- <script src="./ArrayMethods.js"></script> -->
9
9
<!-- <script src="./WebApi.js"></script> -->
10
- < script src ="promises.js "> </ script >
11
- < script src ="./index.js "> </ script >
10
+ <!-- <script src="promises.js"></script> -->
11
+ <!-- <script src="./index.js"></script> -->
12
+ <!-- <script defer src="./Dom.js"></script> -->
13
+ < script defer src ="./AsyncAndAwait.js "> </ script >
12
14
< title > Document</ title >
15
+ < style >
16
+ div .clock {
17
+ width : 150px ;
18
+ height : 150px ;
19
+ border : 2px solid crimson;
20
+ border-radius : 50% ;
21
+ display : flex;
22
+ align-items : center;
23
+ justify-content : center;
24
+ position : relative;
25
+ transform : rotate (-90deg );
26
+ }
27
+
28
+ div .second {
29
+ transition : 0.2s ease-out;
30
+ }
31
+
32
+ div .second ::after {
33
+ content : "" ;
34
+ width : 75px ;
35
+ height : 4px ;
36
+ background-color : yellow;
37
+ position : absolute;
38
+ border-end-end-radius : 10px ;
39
+ }
40
+ div .minute {
41
+ transition : 0.2s ease-out;
42
+ }
43
+ div .minute ::after {
44
+ content : "" ;
45
+ width : 75px ;
46
+ height : 4px ;
47
+ background-color : black;
48
+ position : absolute;
49
+ border-end-end-radius : 10px ;
50
+ }
51
+ div .cover {
52
+ width : 15px ;
53
+ height : 15px ;
54
+ background-color : black;
55
+ border-radius : 50% ;
56
+ position : absolute;
57
+ z-index : 1000 ;
58
+ }
59
+ </ style >
13
60
</ head >
14
61
15
62
< body >
16
-
63
+ < h1 id ="timer "> 0</ h1 >
64
+ < div class ="clock ">
65
+ < div class ="cover "> </ div >
66
+ < div class ="second "> </ div >
67
+ < div class ="minute "> </ div >
68
+ </ div >
69
+ < ul > </ ul >
17
70
</ body >
18
71
19
72
</ html >
Original file line number Diff line number Diff line change 84
84
85
85
const response = fetch ( 'http://jsonplaceholder.typicode.com/users' ) //fetch returns promise
86
86
87
- response . then ( ( dataStream ) => { // showing the promise
87
+ response . then ( ( dataStream ) => { // showing the promise
88
88
console . log ( dataStream )
89
89
const jsonData = dataStream . json ( ) // again it is returning promise with data as array
90
- jsonData . then ( ( data ) => {
90
+ jsonData . then ( ( data ) => {
91
91
console . log ( data )
92
92
} )
93
93
@@ -97,4 +97,11 @@ response.then((dataStream)=>{ // showing the promise
97
97
// console.log(error)
98
98
// })
99
99
100
+ // we can also reduce it further to
101
+
102
+ response
103
+ . then ( dataStream => dataStream . json ) // first fetch is returning us a promise then we (.json) function will conver it into json and return it as promise
104
+ . then ( jsonData => console . log ( jsonData ) ) // previous promise is stored in jsondata and we consoling it
105
+ . catch ( error => console . log ( error ) )
106
+
100
107
You can’t perform that action at this time.
0 commit comments