diff --git a/index.html b/index.html new file mode 100644 index 0000000..295fee0 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + Random Quote Generator + + +

+ + + + + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..8242ea8 --- /dev/null +++ b/script.js @@ -0,0 +1,33 @@ +$(function() { + var ul = $('ul'); + var myHeaders = new Headers({ + "X-Mashape-Key": "V6MbXJDZysmsh47slacZuCcATTLap1OEWHjjsnT7mLwcOTxTAU" + }); + + var myInit = { Method: 'POST', + headers: myHeaders + }; + var url = "https://andruxnet-random-famous-quotes.p.mashape.com/?cat=movies&count=10" + + $('button').on('click', function() { + fetch(url, myInit) + .then((response) => { + // console.log('fetched') + return response.json() + }) + .then(data => { + data.forEach(function (element) { + var quote = element.quote; + var author = element.author; + var $p = $('

').text(`Author: ${author}`) + var $li = $('

  • ').text(`Quote: ${quote}`); + ul.append($li, $p) + }) + }) + .catch((err) => { + // console.log(err) + }) + }) + + +});