-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (64 loc) · 2 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tronald Dump</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<header>
<div class="logo-section">
<img
src="./donald-trump-wearing-red-nose.jpg"
alt="Dumbest things donald trump ever said."
/>
</div>
<div class="heading">
<h1>Dumbest things Tronald has ever said.</h1>
</div>
</header>
<div class="wrapper">
<main>
<div class="tweet-area">
<p class="tweet-heading"></p>
<hr />
<p class="tweet-data"></p>
</div>
<button>Generate Random tweet</button>
</main>
</div>
<footer>
<p>
Made with ♥ By
<a href="https://github.com/svikas641" target="_blank">Vikas Kumar</a>
using this super awesome api -
<a href="https://github.com/tronalddump-io/" target="_blank"
>tronalddump.io</a
>
</p>
</footer>
<script>
const tweetHeading = document.querySelector(".tweet-heading");
const tweetData = document.querySelector(".tweet-data");
const button = document.querySelector("button");
const baseurl = `https://api.tronalddump.io/random/quote`;
async function getQuote() {
try {
button.textContent = `Loading...`;
const response = await fetch(baseurl);
const data = await response.json();
const [tweetDate] = data.appeared_at.split("T");
tweetHeading.textContent = `What Tronald thinks about: ${data.tags[0]}`;
tweetData.textContent = `"${data.value}" - ${tweetDate}`;
button.textContent = `Generate Random tweet`;
} catch (error) {
tweetData.textContent = error;
}
}
// on page load to show something
getQuote();
button.addEventListener("click", getQuote);
</script>
</body>
</html>