From 989fb1c34d6a9f49aab15362516b3113356ef41d Mon Sep 17 00:00:00 2001 From: Janae Stewart Date: Fri, 5 Feb 2021 01:26:13 -0500 Subject: [PATCH] I completed the challenge: 2; I feel good about my code: 2; I need more practice --- myAnswer/index.html | 25 +++++++++++++++++++++++++ myAnswer/js/main.js | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 myAnswer/index.html create mode 100644 myAnswer/js/main.js diff --git a/myAnswer/index.html b/myAnswer/index.html new file mode 100644 index 0000000..f3a0582 --- /dev/null +++ b/myAnswer/index.html @@ -0,0 +1,25 @@ + + + + + + + + What Would Kanye Do? + + + + + + + +

Kanye Thought of The Day

+ + +

Hi I'm Kanye:

+ +

:

+ + + + \ No newline at end of file diff --git a/myAnswer/js/main.js b/myAnswer/js/main.js new file mode 100644 index 0000000..e471273 --- /dev/null +++ b/myAnswer/js/main.js @@ -0,0 +1,16 @@ +//Example fetch using pokemonapi.co +document.querySelector('button').addEventListener('click', getFetch) + +function getFetch(){ + const url = 'https://api.kanye.rest' + + fetch(url) + .then(res => res.json()) // parse response as JSON + .then(data => { + console.log(data) + document.querySelector('h2').innerText = data.quote + }) + .catch(err => { + console.log(`error ${err}`) + }); +} \ No newline at end of file