How to create a function that returns database data?

I’m new to Thunkable and want to use functions. I’ve looked at the documentations and it hasn’t really helped (it only states what you can do not how you can do it)

I’m trying to create a function that takes in a variable and returns a value. The value can either be nothing (because the data wasn’t found) or a property of the results.

The problem is that it’s highly inconsistent.

This is the setup I have now and sometimes it will return a value and other times it wont. Even when I’ve changed absolutely nothing.

I’ve tried the if ___ return as well but I don’t know how to get it to work?

How exactly do you use functions? And how do you use them with RealTimeDB

Hi, @temi.giwa! :wave:
Try removing the if block :smile:

Thanks @kartik14 I tried that and it worked!

Then 10 mins later tested the app again and it stopped working. It returns the variable workout_status 's original value

1 Like

So after much struggling decided to use the Firebase web API based on this answer: How to filter/sort values on Firebase

So much more flexible

1 Like

So, if I helped you,

Please mark my post above as the solution :white_check_mark:
Then the forum will clear this topic from the unsolved topics, and move it to solved topics :wink:

Thanks! :blush: