From a85035be4e2e361480dd38e1778901f4cc6512b6 Mon Sep 17 00:00:00 2001 From: Balogun Ridwan Babatunde <26006774+ridbay@users.noreply.github.com> Date: Mon, 10 Jun 2019 07:45:15 +0100 Subject: [PATCH] Update main.js to fetch quotes from a working endpoint --- js/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/main.js b/js/main.js index 338704e..b34a70c 100644 --- a/js/main.js +++ b/js/main.js @@ -3,15 +3,16 @@ $(document).ready(function(){ getRandomQuote(); }); function getRandomQuote(){ - var color=['#F64747','#663399','#4183D7','#22313F','#9A12B3','#03A678']; /* array of hex color */ - var index=color[Math.floor(Math.random()*color.length)]; /* random color from color array */ + let color=['#F64747','#663399','#4183D7','#22313F','#9A12B3','#03A678']; /* array of hex color */ + let index=color[Math.floor(Math.random()*color.length)]; /* random color from color array */ $.ajax({ - url: 'https://talaikis.com/api/quotes/random/', + url: 'https://quota.glitch.me/random', /* make a request to this endpoint works */ type: 'GET', dataType: 'json', success: function(data) { - var quote=data.quote; - var author=data.author; + // alert(`${data.quoteText} -${data.quoteAuthor}`); + let quote=data.quoteText; + let author=data.quoteAuthor; $('.quote #data').html(quote); $('.quote h4').html("-"+author); $('body').css('background-color', index);