I just discovered a VERY simple and fast way to get and set Firebase data without using the GET or SAVE blocks (which has all sorts of asynchronous issues).
The 2 any button click blocks below return the same data. Just put the GET block KEY variable into the CLOUD variable name and PRESTO. You have a synchronous call to firebase!
Similarly, you can set data anywhere in the JSON Hierarchy using cloud variables. Both of the examples below update Firebase, but the CLOUD based solution does not have the timing issues of the SAVE Block
Hey!
Nice one, it’s really good and will help me retrieve DB information without so much code.
I know that this isn’t relevant, but if you know all the text that you are putting in the join block (that means there is no ‘get text’ or variable or holder for text you don’t know) then why did you use the join block? If the join block has some use, please share it here. I would love to know that because one of my favorite blocks is 'join’
I’m surprised that the Thunkable team has not added this conversion to the official documentation. @domhnallohanlon has suggested in other posts that the goal is for users to move away from get and save, but the docs don’t show you can do this
The error would typically be that the key doesn’t exist, right? I feel like I did try to figure out what value is returned by an invalid key but I can’t remember what it was. Easy enough to test and if it gives a specific value, to then check for that.
Hmmm… well, without error control, using cloud variables is kind-a-pointless, unless of course you are super confident about the successful execution of the operations. To be honest, I don’t have much experience with the Realtime DB so maybe I will find the answer as I dig deeper into the rabbit hole.
I guess my take on it is that I’m using a Firebase data set that I created using Thunkable so I’m always going to know how the data is structured and I’ll always have permission to access it. But I can see how that wouldn’t necessarily be the case for everyone.
Also, would you happen to know how to use two way authentication with firebase to log in? I saw the document explanation for it within the docs section of thunkable, but it isn’t working correctly for me. I’m new to this and need all the help I can get!