Random Quote Generator - worked a while ago, now it doesn't

Hey folks, in the process of applying for new jobs and want to make sure my portfolio isn’t all janky. For some reason I cannot get my Random Quote Generator working. It looks like the site that originally hosted where I pull the quotes from changed, but even after changing it to the correct site and updating the key I’m unable to get a random quote to display. Everything else looks like it’s working fine.

Here’s the JS code:

$(document).ready(function() {
  // Loads quote on page load
  getQuote();

  $("#getQuote").click(getQuote);
});

function getQuote() {
  $(document.body).css('background-color', colors[Math.floor(Math.random() * colors.length)]);
  $.ajax({
    type: "POST",
    url: "https://andruxnet-random-famous-quotes.p.rapidapi.com/?count=10&cat=famouss",
    responseType: "json",
    success: function(response) {
      showQuote(response);
      $('#tweet-quote').attr('href', 'https://twitter.com/intent/tweet?text=' + encodeURIComponent('"' + response.quote + '" - ' + response.author));
    },
    error: function() {
      alert('Error retreiving quote');
    },
    beforeSend: setHeader
  });

  function setHeader(xhr) {
    xhr.setRequestHeader("x-rapidapi-key", "sUHZ623ia5mshGZPh9XMvWs06Ltcp1zBgy1jsnyx6wQE0Wwnxl");
    xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    xhr.setRequestHeader("Accept", "application/json");
  }
}

function showQuote(response) {
  console.log(response);

  $('#quote').text(response.quote);
  $('#author').text(response.author);
}

var colors = [
  '#4286f4',
  '#f4417a',
  '#58f441',
  '#41f4f4',
  '#f1f441'
]

Any help would be greatly appreciated.

The quote is in an array. Try modifying the code in showQuote to response[0].quote, etc.

Where’s the quote in an array?

Also, I think I might have figured it out… it looks like I’m on an old “plan” and I need to subscribe.

Edit: You are correct - it was in an array. Still confused as it was definitely working as of April of 2018. I also had some issues with having the right URL.

For anyone curious, this is what I had to change:

This:

url: "https://andruxnet-random-famous-quotes.p.mashape.com/?cat=famous",

To this:

url: "https://andruxnet-random-famous-quotes.p.rapidapi.com/?count=1&cat=famous",

This:

xhr.setRequestHeader("X-Mashape-Key", "pmTSpn6I45mshpuPkHokTQ01lAo1p1ugEH1jsnoOS19Gk3KQvB");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

To this:

xhr.setRequestHeader("x-rapidapi-key", "sUHZ623ia5mshGZPh9XMvWs06Ltcp1zBgy1jsnyx6wQE0Wwnxl");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");

And this:

$('#quote').text(response.quote);
$('#author').text(response.author);

To this:

$('#quote').text(response[0].quote);
$('#author').text(response[0].author);

Appreciate the help!