# List of info from RealTime DB only populating on second click

**URL:** https://community.thunkable.com/t/list-of-info-from-realtime-db-only-populating-on-second-click/980674
**Category:** Questions about Thunkable X
**Tags:** firebase, lists, list, push-notifications, realtimedb
**Created:** [November 17, 2020, 5:48pm UTC](https://community.thunkable.com/t/list-of-info-from-realtime-db-only-populating-on-second-click/980674 "2020-11-17T17:48:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sgreenb8pg4sn9](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@sgreenb8pg4sn9](https://community.thunkable.com/u/sgreenb8pg4sn9)
#### Post date: [November 17, 2020, 5:48pm UTC](https://community.thunkable.com/t/list-of-info-from-realtime-db-only-populating-on-second-click/980674/1 "2020-11-17T17:48:59Z")

</div>

Hello, I’m having a weird issue when I try to create a list of data retrieved from Realtime DB. My app has a database of user IDs and each user is also assigned a play ID from OpenSignal so that I can send push notifications. What my code does is go through each user that I want to send a notification to and gets their play ID. However, when I click the button that triggers this function and displays the list, the list isn’t displayed. But when I click the button again, the list is displayed! I really don’t understand why this is happening. Any help would be appreciated.

This is the structure of my database (there are two types of users - customers and businesses):

 ![Screen Shot 2020-11-17 at 12.44.55 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/b/4b74efcf61402bcadfa8d36fb698eaeba35ea559.png)

and this is my block:

 ![Screen Shot 2020-11-17 at 12.47.12 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/1/b11460b84f4c1433526dcd1b9a8f2bb34812a24d.png) ![Screen Shot 2020-11-17 at 12.47.23 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/7/a7e7d85ef65168446619d639cdf08a2abcca861d.png)

When I click the button to display the usersToNotify list, it is blank. But then when I click the button again it displays. Any help would be appreciated!

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [November 17, 2020, 6:03pm UTC](https://community.thunkable.com/t/list-of-info-from-realtime-db-only-populating-on-second-click/980674/2 "2020-11-17T18:03:17Z")

</div>

You are not alone!

The firebase GET and SAVE blocks are asynchronous (as evidenced by the THEN DO section). When you put them in a loop or execute one after the other, erratic behavior is the norm. I have found 2 solutions to the problem.

> [@Replace GET or SAVE Blocks with cloud variables](http://community.thunkable.com/t/thunkable-hack-deep-firebase-json-data-manipulation-without-using-get-or-save-blocks/975738):
>
> 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…

> [@Wrapping Asynchronous (then do) blocks into a Synchronous Function resolves unpredictable results](http://community.thunkable.com/t/wrapping-asynchronous-then-do-blocks-into-a-synchronous-function-resolves-unpredictable-results/910511):
>
> Thunkable provides an extensive library of calls to external services including Google Docs and Web APIs. These external calls are, by necessity, asynchronous calls. That is, the request is sent to the external serivce, Thunkable block execution continues on it’s merry way, then the external service sends a reply. Thunkable wraps the external calls in in blocks with “Then Do” sections. This is a massive improvement over separate call and response block (MIT App Inventor), but it is not without …

---

<div class="post-metadata">

### Author: ![sgreenb8pg4sn9](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@sgreenb8pg4sn9](https://community.thunkable.com/u/sgreenb8pg4sn9)
#### Post date: [November 17, 2020, 6:51pm UTC](https://community.thunkable.com/t/list-of-info-from-realtime-db-only-populating-on-second-click/980674/3 "2020-11-17T18:51:32Z")

</div>

Thank you!!! I was trying to figure out this issue for so long and this worked. You’re a life saver!

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 12:21pm UTC](https://community.thunkable.com/t/list-of-info-from-realtime-db-only-populating-on-second-click/980674/4 "2024-11-08T12:21:38Z")

</div>


