Api isnt working in my random quote machine

When I console logged the quoteText it returns an error.Can you reason out why?

Not without a link to your codepen project so we can see what may have gone wrong! I’ll take a look if you leave the link.

Oh sorry, I forgot it here is the link to my project

So the issue was in your url. Change it to http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&lang=en&format=jsonp&jsonp=? If you replace this your console log will show the quote text.

You’ll see it’s very similar to your original url except the format has been changed to jsonp, with &jsonp=? added to the end. Now why does it work with jsonp and not just json? Unfortunately I can’t remember. I ran into this very problem when I did the project. Hopefully someone here more knowledgeable can give you the reason why this change was needed! :slight_smile:

I’ve changed it but it still doesn’t work

Now it works but i have to load codepen using http instead of https.

1 Like

Glad you got that working!