From dee3e3e206dbf5bba5c8f29e415ba530f9a1df80 Mon Sep 17 00:00:00 2001 From: Adeel Bukhari Date: Sat, 20 Feb 2021 22:51:28 -0500 Subject: [PATCH] Add project files --- bbquote.js | 17 +++++++++++++++++ breaking_bad_quote_generator.html | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 bbquote.js create mode 100644 breaking_bad_quote_generator.html diff --git a/bbquote.js b/bbquote.js new file mode 100644 index 0000000..8b53afd --- /dev/null +++ b/bbquote.js @@ -0,0 +1,17 @@ +document.querySelector('button').addEventListener('click', getQuote) + +function getQuote(){ +const url = "https://breaking-bad-quotes.herokuapp.com/v1/quotes/" + +fetch(url) + .then(res => res.json()) // parse response as JSON + .then(data => { + document.querySelector("h2").innerText = data[0].quote + document.querySelector("h3").innerText = data[0].author + + }) + .catch(err => { + console.log(`error ${err}`) + }); + + } diff --git a/breaking_bad_quote_generator.html b/breaking_bad_quote_generator.html new file mode 100644 index 0000000..ef4d139 --- /dev/null +++ b/breaking_bad_quote_generator.html @@ -0,0 +1,21 @@ + + + + + + Document + + + + +
+
+ + + +

+

+ + + + \ No newline at end of file