Should I use the debug labels exactly as they were shown in one of the screenshots above?
When you evaluate your code, it helps to go line by line (or block by block) and ask yourself âWhat do I expect to happen?â AND âWhat actually happens?â
In looking at your code, I would expect the variable called âmessageâ to have no value because you havenât set one. So when you set the Debug labelâs text to the variable âmessageâ and get the error âundefinedâ, that would be the expected outcome. That variable IS undefined.
The most important block in your code is the âset app variable carbohydrates_100gâ block because everything else youâre trying to do depends on that block. So if I were you, I would be setting the Debugâs Text to that variable. And then considering âwhat value do I expect to see?â Thatâs going to depend on the JSON response but letâs just say weâre expecting the value 23. Okay, so do we get 23 in the Debug label? Or do we get some other number/word? Or do we get an error/white screen crash?
Once you are sure that the Debug label is getting the right value every time, then you can worry about checking to see if the âcarbohydrates_100gâ variable is less than or greater than or equal to a certain value.
Edit: I just saw the function you created (WAIT and report). Itâs possible that the variable âmessageâ is getting set there but I donât think it is. Youâd have to use a function variable which is different.
Oh, and because you want the Debug label to show the value no matter what, make sure itâs not inside an if block. Put the âset Debugâs Text toâ block right below the âset app variable carbohydrates_100g toâ block.
So all the debug labels should always be outside an if block?
That indicates that thereâs a problem with your JSON parsing. So I would go back to the formatted JSON in a browser and make sure you are getting the right property.
What barcode value are you using in your Web API URL?
It youâre still using this URL:
https://world.openfoodfacts.org/api/v0/product/04963406
Then the âproductâ property is not a list/array. So you canât get list item #56 of that property as youâre attempting to do. You should remove the âin list [ ] get # 56â block.
Yes, I am using that url.

Is that better?
I really like this JSON formatter I just found:
You can paste in the full JSON response on the left side and click Tree Viewer. Then, on the right side, you can search for a property such as ânutrimentâ, click on âcarbohydrates_100gâ below it and see the path to that property at the top (object â product â etc.).
When I do the live test the debug label says âvalueâ and the barcode scanner label says âundefinedâ. What does that mean?
If your app keep crashing then you need to localize the problem first. If I were you I would first remove the Get property block all together and assign the app variable carbohydrates_100g a direct value. Then run the app and see if it still crashes.
at least, if it crashes then you know your get property block is OK and if the program worked without this block then you have localized the code with the problem.
Happy Thunking.
When I took the get property block out and assigned the direct value of app variable carbohydrates_100g, the app did not crash. And the debug label said âvalueâ after I did a live test. So what would I need to change now?
OK, so firstly, thereâs a lot thatâs missing with your code. And if Iâm not wrong, the deadline is coming closer.
Letâs do it step by step.
Your if not error and if status = 200 is wrong. Youâve done
if not error
if status = 200
(bla bla bla)
else set Errorâs text to error.
Here, you are connecting the error display with the event of the status not being 200.
You should actually put it in the else block connected the if not error statement.
In the else block connected to the if status = 200, you should put
set Statusâs text to status(not the text âstatusâ, the green block.).
Your end result should look like this:

I tried this type of debugging and I get âvalueâ in the debugging box.

And Iâm still not getting the healthy/unhealthy text. Could someone please let me know soon what I need to fix? Sorry, this is just very urgent and I need to get this finished in the next couple of hours.
What have you initialized carbohydrates_100g to? Where have you initialized it? Are you changing the value after every function? What are you comparing again 15.9/16?
Yes I am comparing 15.9/16
This is where I intialized it:

Also, you should download the Thunkable Live app and test this. This seemd to be a webpage from which you are we testing.








