Hi campers! Again, I am here in need of help.
Random Quote Machine
This is my first API-related project. I’m not sure why my code isn’t working in CodePen. I watched a YouTube video where he did the exact same thing and got a new quote every time he clicked the quote button. I managed to achieve my goal with jQuery but wanted to know why this code isn’t working in CodePen. Is there anything else that should be included? or a different thing?Please help.
I would add a
console.log(results) inside your last
then and check if the value is what you expect
@ilenia I have
console.log(results).It is showing an object of quotes.
But when I
console.log(results.json(). It is showing an error.
yeah, so you don’t have
And it’s an array of quotes, so you need to plan your code differently
why are you doing that? you already converted the json
results had already been converted from JSON, if you’re seeing the array of quotes. It’s already an object, so you can’t re-convert it.
@snowmonkey @ilenia Yes, you are right, my mistake.
New Quote button, it still gave the same error. It’s displaying blank quotes on the screen.
I don’t see any changes in your code in the codepen
@ilenia Thank you so much for your help. I have figured it out.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.