Skip to content

Commit e668ca4

Browse files
committed
1 parent ffbb65b commit e668ca4

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

index.html

+56-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,66 @@
77
<!-- add js file -->
88
<!-- <script src="./ArrayMethods.js"></script> -->
99
<!-- <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>
1214
<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>
1360
</head>
1461

1562
<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>
1770
</body>
1871

1972
</html>

promises.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484

8585
const response = fetch('http://jsonplaceholder.typicode.com/users') //fetch returns promise
8686

87-
response.then((dataStream)=>{ // showing the promise
87+
response.then((dataStream) => { // showing the promise
8888
console.log(dataStream)
8989
const jsonData = dataStream.json() // again it is returning promise with data as array
90-
jsonData.then((data)=>{
90+
jsonData.then((data) => {
9191
console.log(data)
9292
})
9393

@@ -97,4 +97,11 @@ response.then((dataStream)=>{ // showing the promise
9797
// console.log(error)
9898
// })
9999

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+
100107

0 commit comments

Comments
 (0)