Fixed: Unable to Pull New Data from API for Random Quote Generator

Fixed: Unable to Pull New Data from API for Random Quote Generator
0

#1

I’m working on the Random Quote Generator project and am experiencing a minor issue.
The API I’m using (Quotes on Demand) is requested using http. So I modified the call to use https to avoid the blocked mixed content error.
When I navigate to “https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=” in a new tab it has no trouble using the secure connection and fetching a new quote each time. However, in my code_pen I just wind up fetching the same data with each call. (pen: https://codepen.io/PickleRick69/pen/KZVEBp/)
Is code_pen just blocking these requests, or am I just making a dumb rookie mistake?


#2

Quotes on Design caches the results by default, so you must tell it not to do that. Put the following somewhere before you make the getJSON call;

$.ajaxSetup({cache:false});

#3

That was a quick fix. Thank you so much for the help.