# How do i iterate through data stored in firebase database using thunkable

**URL:** https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450
**Category:** Questions about Thunkable X
**Tags:** firebase, beginner
**Created:** [September 1, 2024, 6:20pm UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450 "2024-09-01T18:20:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![yasarbains7mhf9pj](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yasarbains7mhf9pj](https://community.thunkable.com/u/yasarbains7mhf9pj)
#### Post date: [September 1, 2024, 6:20pm UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/1 "2024-09-01T18:20:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/5/35f9a720915ad66844b1812018748c291ba7462f.png)  
This my firebase database, now I want to iterate over each object inside the chat object, and I only want to check with the immediate child of chat that whether a particular email address is present or not. Please help me out with this.  
Thank you.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [September 1, 2024, 8:58pm UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/2 "2024-09-01T20:58:34Z")

</div>

Here’s how to do this:

Project link: [Thunkable](https://x.thunkable.com/copy/4294b64cbd16f4ac47439e87c7807953)  
(See first screen with your username)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/1/517d2c29ecc526023410247ebaaafbc0440ba80b.png)

---

<div class="post-metadata">

### Author: ![yasarbains7mhf9pj](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yasarbains7mhf9pj](https://community.thunkable.com/u/yasarbains7mhf9pj)
#### Post date: [September 2, 2024, 6:49am UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/3 "2024-09-02T06:49:59Z")

</div>

```auto
"chat": {
  "yasarbains03@gmail^com": {
    "chatList": [
      {
        "author": "Sender",
        "message": "Sample text message"
      },
      {
        "author": "Sender",
        "message": "Hey"
      },
      {
        "author": "Sender",
        "message": "Hi"
      }
    ]
  },
  "yasarbains15@gmail^comyasarbains7@gmail^com": {
    "chatList": [
      {
        "author": "Sender",
        "message": "Sample text message"
      },
      {
        "author": "Sender",
        "message": "Hi"
      },
      {
        "author": "Sender",
        "message": "Hey"
      }
    ]
  },
  "yasarbains7@gmail^com": {
    "chatList": [
      {
        "author": "Sender",
        "message": "Sample text message"
      },
      {
        "author": "Receiver",
        "message": "Hi"
      },
      {
        "author": "Sender",
        "message": "Hiii"
      },
      {
        "author": "Sender",
        "message": "Hello"
      },
      {
        "author": "Sender",
        "message": "hi"
      },
      {
        "author": "Sender",
        "message": "Hi"
      },
      {
        "author": "Sender",
        "message": "heyyy"
      },
      {
        "author": "Sender",
        "message": "Hii"
      }
    ]
  },
  "yasarbains7@gmail^comyasarbains15@gmail^com": {
    "chatList": [
      {
        "author": "Receiver",
        "message": "Hey"
      }
    ]
  }
}

```

The chat object is of above form, and in this I want to search for, for example - yasarbains15@gmail^com, such that this email comes in a combination with some other email and this email is present first then the second email, like, “yasarbains15@gmail^comyasarbains7@gmail^com”.This can be done if I only read the email addresses and not the chatList inside email address. Is there any way to do that?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [September 2, 2024, 7:16am UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/4 "2024-09-02T07:16:39Z")

</div>

Try it… you can change the search term to whatever you like in my demo project.

Why do you have two email addresses joined together as a single property name?

---

<div class="post-metadata">

### Author: ![yasarbains7mhf9pj](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yasarbains7mhf9pj](https://community.thunkable.com/u/yasarbains7mhf9pj)
#### Post date: [September 2, 2024, 7:24am UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/5 "2024-09-02T07:24:44Z")

</div>

Okay, let me check.  
I am creating a chatting option in my app for customers and service providers, and in-order to store there chats, and fetch them for later display I am using two email addresses as unique key, so the chats will be stored as sender’s email + receiver’s email.

---

<div class="post-metadata">

### Author: ![yasarbains7mhf9pj](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yasarbains7mhf9pj](https://community.thunkable.com/u/yasarbains7mhf9pj)
#### Post date: [September 2, 2024, 7:56am UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/6 "2024-09-02T07:56:04Z")

</div>

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

When I using my script in sampleJSON, and trying to print the child of chat object, I am getting null. Is there any way to read this form of JSON script?

---

<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: [September 2, 2024, 6:30pm UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/7 "2024-09-02T18:30:08Z")

</div>

Hello @yasarbains7mhf9pj  
You are getting null because the “samepleJSON” variable doesn’t contain a JSON. A valid JSON should be inside these { }.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [December 1, 2024, 6:30pm UTC](https://community.thunkable.com/t/how-do-i-iterate-through-data-stored-in-firebase-database-using-thunkable/3170450/8 "2024-12-01T18:30:40Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
