[Quote Machine] - Every quote I get through API is the same quote

Hi guys,

I completed the Quote Machine App except it’s not working correctly. I have used this API: https://quotesondesign.com/api-v4-0/

It says that this link: http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1
Should give me 1 random quote. It does but after I have this quote and call it again it’s the exact same quote.

Here is my CodePen: https://codepen.io/GeraltDieSocke/pen/OxXJJr

Can anyone tell me what’s going on?

The result is most likely cached.

Hey. quotesondesign caches its results, therefore you just need to set the cache for your call to false by adding the following in your JS:

$.ajaxSetup({
  cache:false
})

Or, since you’re using jQuery 3, you could modify your .getJSON like so:

  $.getJSON({
    url: "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=",
    cache: false
  }).then(function(a){
    var quote = a[0].content;
    var title = a[0].title;
    
    $(".quote").html(quote);
    $(".title").html("-" + title);   
  });