I am trying to create a scripture trivia game that generates a random scripture reference and pulls the text for that scripture from an API. I have it working for a reference that includes one or two verses, but I am running into problems once I get to three or more verses. It seems like I am getting the first and last, but nothing in the middle.
Here is the json response
{
"api": {
"q": "Isaiah 58:6-8",
"format": "json"
},
"scriptures": [
{
"scripture": "Isaiah 58:6",
"book": "Isaiah",
"chapter": 58,
"verse": 6,
"text": "Is not this the fast that I have chosen? to loose the bands of wickedness, to undo the heavy burdens, and to let the oppressed go free, and that ye break every yoke?"
},
{
"scripture": "Isaiah 58:7",
"book": "Isaiah",
"chapter": 58,
"verse": 7,
"text": "Is it not to deal thy bread to the hungry, and that thou bring the poor that are cast out to thy house? when thou seest the naked, that thou cover him; and that thou hide not thyself from thine own flesh?"
},
{
"scripture": "Isaiah 58:8",
"book": "Isaiah",
"chapter": 58,
"verse": 8,
"text": "Then shall thy light break forth as the morning, and thine health shall spring forth speedily: and thy righteousness shall go before thee; the glory of the LORD shall be thy rereward."
}
]
}
Here is my block where Iâm storing the data in a string variable
Yes, Iâm getting all of the data from the API (api.nephi.org). Iâm new to the platform and hesitant to share the project, but I did include a screen shot of the code that is exhibiting the weird behavior, should be fairly quick to reproduce it!
There is nothing wrong with your blocks or with Thunkable. I suspect this might be the cause from the APIâs website:
Books, chapters and verses that donât exist will simply not be included, no errors or empty placeholders are shown.
I can see why you thought the first and last verses were the only ones working. But if you do more extensive testing of your project, youâll notice that some single verses (e.g. Psalm 119:105) do not display at all and some that should have two or more verses only display one (e.g. Doctrine & Covenants 76:22-24). The missing data is not included in the API response.
You can check this by adding a Text Input component and setting its text value to the green response block. Then, when you click Reveal Answer, copy the Text Inputâs text from Thunkable Live. Paste it into Best JSON Viewer and JSON Beautifier Online to format it in a viewable tree.
Edit: I think actually that the API does return the full set of verses most of the time. But something about the url you are using to call the API doesnât return a full set of verses. Iâm not sure why yet!