Hey guys I’am stuck . My random Quote Machine only generates the same Quote over and over again.
My Pen: https://codepen.io/Rosaroterpanther/pen/VWPbYL
the API I use: https://quotesondesign.com/api-v4-0/
I don’t understand why I always get the same result.
My Code:
//getMessage is my Button to generate new Quote, m is my div where i want to place the quote
var btn = document.getElementById("getMessage");
var quoteContainer = document.getElementById("m");
var count = 0;
btn.addEventListener("click", function(){
$.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", function(a) {
addHTML(a);
});
});
function addHTML(data){
var curQuote = "";
curQuote = data[0].content + "<p>— " + data[0].title + "</p>";
count++;
quoteContainer.innerHTML = count + ":" + curQuote;
}