# Iterate/Loop over lists vs objects from firebase request

**URL:** <https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, beginner, lists\
**Created:** [April 30, 2019, 11:31am UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577 "2019-04-30T11:31:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Menor\_Preco](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Menor\_Preco](https://community.thunkable.com/u/Menor_Preco)\
**Post date:** [April 30, 2019, 11:31am UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/1 "2019-04-30T11:31:28Z")

</div>

I am having many problems with storing entities in firebase. The problem is because when the first entity is registered as a child of an entry, when I do a get request in that entry, I get a list , but when I start adding more childs to that entry, when I do a get request on it, I get an object { }. And it’s easy to iterate over a list, but what can I do when I receive an object ?

[This link](https://firebase.googleblog.com/2014/04/best-practices-arrays-in-firebase.html) talks about my problem. And that’s the illustration of the problem:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/3/23dc1fda618bc369556374176343a7d8b2f970f9.png)

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [April 30, 2019, 10:02pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/2 "2019-04-30T22:02:00Z")

</div>

@Menor_Preco, Do you have an example of a project (hopefully a small one) which demonstrates your problem? If so, could you share it here ([here’s how](http://docs.thunkable.com/share-1))?

-Mark

---

<div class="post-metadata">

**Author:** ![Menor\_Preco](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Menor\_Preco](https://community.thunkable.com/u/Menor_Preco)\
**Post date:** [May 1, 2019, 8:26pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/3 "2019-05-01T20:26:10Z")

</div>

@Mark, I think this is the smallest one I can do:

[https://x.thunkable.com/copy/eb5541012edb7ef550c1bc493d19dde4](https://x.thunkable.com/copy/eb5541012edb7ef550c1bc493d19dde4)

Usage:

1 - Clear Database  
2 - Type a string in the field  
3 - Click to register  
4 - Wait until the firebase requests end  
5 - Wait until the “Registers list” change

You will see that you send a list in the Save Request, but when you do a Get on it, firebase returns an object. And after adding the first register, you can’t add more, because Blockly “crashes” when you try to interpret an object as a list.

---

<div class="post-metadata">

**Author:** ![Menor\_Preco](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Menor\_Preco](https://community.thunkable.com/u/Menor_Preco)\
**Post date:** [May 2, 2019, 11:36pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/4 "2019-05-02T23:36:47Z")

</div>

@Mark, the only way I think I can do what I want is to implement a linked list in firebase, but that’s not a good solution 😕. I’m bugged with firebase. If you get an idea, give me a light.

Many thanks 🙂.

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [May 2, 2019, 11:58pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/5 "2019-05-02T23:58:50Z")

</div>

@Menor_Preco I haven’t had a chance to look at your example project yet. Hopefully, once I do I can find a reasonable solution.

-Mark

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [May 3, 2019, 5:56pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/6 "2019-05-03T17:56:53Z")

</div>

@Menor_Preco . I believe that you have discovered a bug in our code generation. The workaround that I would suggest would be to replace your uses of `Realtime DB` component with [cloud variables](https://docs.thunkable.com/variables). They can do pretty much everything that the `Realtime DB` component does only much more simply and they do not have the bug that is causing your problem.

I hope this helps!

-Mark

---

<div class="post-metadata">

**Author:** ![Menor\_Preco](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Menor\_Preco](https://community.thunkable.com/u/Menor_Preco)\
**Post date:** [May 4, 2019, 10:17am UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/7 "2019-05-04T10:17:56Z")

</div>

For now, this solves my problem, thank you !

And I’m also happy to know that I have discovered that bug, I hope this help. 🙂

@Mark, I don’t know if is possible, but I have one doubt: how can I know if the Save Request of the cloud variable failed ?

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [May 4, 2019, 6:28pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/8 "2019-05-04T18:28:06Z")

</div>

> [@Menor\_Preco](#):
>
> how can I know if the Save Request of the cloud variable failed ?

Right now I think the easiest way would be to check whether the cloud variable contains the expected value.

---

<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:13pm UTC](https://community.thunkable.com/t/iterate-loop-over-lists-vs-objects-from-firebase-request/75577/9 "2024-11-08T12:13:53Z")

</div>


