From e975134046b6a095fc12a7838bba3404ab6e3483 Mon Sep 17 00:00:00 2001 From: Ty Liddell Date: Thu, 11 Feb 2021 17:58:48 -0600 Subject: [PATCH] completed simple api and it's working --- .DS_Store | Bin 0 -> 6148 bytes css/main.css | 5 +++++ index.html | 26 ++++++++++++++++++++++++++ js/main.js | 16 ++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 .DS_Store create mode 100644 css/main.css create mode 100644 index.html create mode 100644 js/main.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4cb8da52aed97dd6b15dfc59ce40a4d1de75ce98 GIT binary patch literal 6148 zcmeHK%}&BV5Z(pUEyl>fM2>s$#(^J|cra-Y58g~_^q>Y?AyR`ap+%xt)7Q{9@(Fw$ zXLc7NpjTtaOfvh;&dzKzUz_d@V~jV3?FwTB#+U#_%vdn|Ah?dYAQ|Jy0dm|U>U+J= zgV~4IUx+5he`EmPU6$Rlh(+G$`}^zpQCu#6@=P|jvbrWjUgS6O*G@MaIk6iLqlP=U z#M!AEcRgdDg<)@MyWY9q8MO*qM_~}Ve$W}HWWU{kkgE$nXosUlI1Jj6+Q-ogLRi9T z6^i3=b+1~IwemqylH+>4T#~!B{Uou(_D<#SZ2C|o@q z_LnN0aa$ve!~iic%Rp973wZt?|K9)4Cee%-AO@C-0iJ6*%?6ZY&enzE@T`@fH=rmO nmuj4*fT50Jh{dD02&x495)DAxV5$*3AaoH>G|)f{{3!!p3<;2M literal 0 HcmV?d00001 diff --git a/css/main.css b/css/main.css new file mode 100644 index 0000000..5ae1ae8 --- /dev/null +++ b/css/main.css @@ -0,0 +1,5 @@ +* { + text-align: center; + background-color: blue; + color: white; +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..49eee00 --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ + + + + + + + Auto Text + + + + + + +
+
+

Don't Laugh Challenge

+
+

+
+
+ + +
+ + + \ No newline at end of file diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..1a56243 --- /dev/null +++ b/js/main.js @@ -0,0 +1,16 @@ +const joke = document.querySelector('.joke'); +const btn = document.getElementById('btn'); +const jokeParagraph = document.querySelector('.joke p'); + +// Getting data from the Api using Fetch with Async Await Syntax. +btn.addEventListener('click', getRandom); +getRandom(); +async function getRandom() { + const jokeRes = await fetch('https://icanhazdadjoke.com/', { + headers: { + 'Accept': 'application/json' + } + }); + const resJson = await jokeRes.json(); + jokeParagraph.innerHTML = resJson.joke; +} \ No newline at end of file