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

Random Quote Generator

+ +

+ + + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..2fc1dc6 --- /dev/null +++ b/script.js @@ -0,0 +1,30 @@ +$(function () { + var url = 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=famous&count=1' + var init = { + method: 'POST', + headers: { 'X-Mashape-Key': 'xONQa6hJi8mshG1BCCGIKmeiCnjNp1UOu2Bjsn7BkDSLsaR4Ua' } + } + var myRequest = new Request(url, init) + // api call + var apiCall = fetch(myRequest) + + // functions + var returnResponse = response => { + console.log('response received') + return response.json() + } + + var updateRandomQuote = data => { + var $h2 = $('h2') + $h2.text(data.quote) + } + + var logError = error => { + console.log(error) + } + + // logic + apiCall.then(returnResponse) + .then(updateRandomQuote) + .catch(logError) +})