Random Quote Machine, API data don't display

Random Quote Machine, API data don't display
0.0 0


Hi guys!

I am really really stuck in the Random Quote Machine project. I have compared my coding to several other posts in the forum, and my codes seem fine. I just can’t figure out where I did wrong.

Could anyone please tell me what was the problem in my JS file? Thanks a lot!!!



Where are you trying to get data from? The url you pass to ajax resolves to https://codepen.io/wp-json/posts (with a bunch of parameters). That doesn’t feel like a genuine api url as wp-json is a WordPress thing.

Tip: to see if your query is failing, chain a fail promise to your ajax call like so:

    .fail(function(jqXHR, textStatus, error){
      console.log("failed to get data", textStatus, error, jqXHR.status);

This way if it fails you’ll see it in the console and you might get a clue as to why.


Here is the API:

They demonstrated how to use the API, but I think the url was wrong in their codes. Thank you for pointing that out! Now I have corrected the url and it works!! Thank you so much!!!