Help with Forismatic API/JSON GET Request

Hey guys, so I’m struggling with pulling data from the Forismatic API ( for this project.

From the API documentation I know the data is formatted with tags like “quoteText” & “quoteAuthor” which is the data I require, however I can’t figure out how to pull this from the API.

In the link below you will see I’ve attempted to iterate through the JSON object and append the required info to the required div but so far I’m not having any joy.

It’s my first time using jQuery for a project so it’s very possible that I’ve made some glaring errors! Help would be greatly appreciated.

Thanks in advance!

Using this api call :

I got the following response in JSON :
{“quoteText”:“It is not enough to have a good mind; the main thing is to use it well. “, “quoteAuthor”:“Rene Descartes “, “senderName”:””, “senderLink”:””, “quoteLink”:“”}

If you paste that response in a json validator it helps to visualize what you want to get out of it. Personally I use

In order to access the quote text and author I would try this

P.S. - It’s always helpful to just paste your api call into your browser to see what response you get to verify correct syntax.


Thanks that’s exactly what I was looking for!

Do you know of a way I can view the JSON data I’m pulling without using the chrome console? Unfortunately my current set up is an android tablet so I’m unable to use the console!

EDIT: Apologies I’ve only just seen your comment about pasting the API call into the browser to check the result, I had no idea this was possible thanks!

1 Like

No problem! Happy to help, I’m just a beginner as well so take everything I said with a grain of salt

You will not be able to change the inner HTML of an element of create a new HTML element and change its inner value using JSON due to Cross-Origin Resource Sharing (CORS) as your browser will block a cross-origin request. You will need to use the JSONP format to do what you are trying to achieve.

This is because browser security does not allow data exchange if the data is of different origin than you origin of your website.

Postman will help you see the JSON data clearly. It will give you an idea that what you need to include in you r app. Hope this will help you.

1 Like

Where do I find this link?

The Forismatic API:

Check this url

1 Like

Thanks Claret! 1 month later hahaha

this is what worked for me: datatype jsonp with https request.

otherwise, i was getting a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error. this is something to with cross domain blocking by browser