How to create nutrition app with ocr scanner?

Against what variable are you comparing 15.9 and 16?

I did try it on my phone with live app I get the same error except for the barcode scanner error

The value of the carbohydrates_100g

That doesn’t make sense. That means you are checking whether the word “value” is smaller than 15.9! Can you please share your entire, updated code once more?


1 Like

Where is your ‘get property…’ code?

@muneer told me to remove it, because it caused my app to crash

1 Like

You haven’t added that. Against what should you compare 15.9 and 16?

Try adding it again. What you’re doing is comparing 15.9 and the word value. That doesn’t make sense at all. The computer also gets confused. That’s why you don’t get your healthy/not healthy value.

This is what I get when I added the “get property” block
image

1 Like

Have you added a grey border to your screen? Because this doesn’t look like the Live Test app on the phone.

Download this:

Yes, it’s expected that you get ‘value’, because that’s what your variable contains.

This is what it looks like on my phone:


The value goes from 1 to 11 but never says anything in the health/unhealthy boxes (which are red and green)

Yes, I told you to try to localise the crash problem. Not to remove it for good. Now you know for certain that what crashes your app is something to do with the get property block that you are using.

This step does not solve the issue or any other issue but it pin point the faulty coding block.

Happy Thunking!

2 Likes

Thank you for clarifying! I watched all the tutorial on how to use the get property blocks and how to parse it properly but I can’t find the error in the get property block. Can you see a problem with the way this is set up?

This is my web api url: https://world.openfoodfacts.org/api/v0/product/04963406

I think you should share the link to your project because seeing individual screenshots doesn’t really paint a full picture of how you have things set up.

Those blocks on their own should work. But it’s what you have above and below them that also matters. And make sure you’re testing this on your phone in the Thunkable Live app, not in a browser.

2 Likes

I would like to share my project privately…is there a way to do that?

You can send the link in a private message to any recipients you choose. I don’t know that I’ll have time to help today but you’re welcome to send it to me.

2 Likes

Okay, thank you! I added a few people on it. It would be great if you guys could take a look at that!

1 Like

One problem right off the bat is that your URL is wrong. You added a static barcode (04963406) to the URL and then you’re joining it with whatever the barcode scanner returns.

So if you scan a barcode that has the value 04963406, your URL is going to be https://world.openfoodfacts.org/api/v0/product/0496340604963406.json which is an invalid API call.

This could have been fixed easily by assigning a label to the Web API’s URL – remember to check variable values at each step.

1 Like