Problem while retrieving values from Firebase

I am receiving empty string from Firebase even though I have successfully got the tag list but when I use the ‘for’ loop to get values for each tag, I am receiving empty strings. I want to retrieve my FriendsList which has 2 phone numbers and also I want the values which are inside the Chats bucket. Here’s my database structure and the blocks.

PS - The mobile numbers are hidden for security reasons.

I need the tag list which is inside the FriendsList bucket.

As you can see in the image, there are two buckets inside FriendsList

  1. 9187449****0
  2. 9198508****6

So I have simply set my project bucket to Users/9186988****5/FriendsList/ and then GetTagList block. I successfully received 2 values in the list which are correct. So I have used the ‘for’ loop to get the tags and values which are inside the Chats bucket and used GetTagList block again to get the tags of the Chats bucket. I have got all the tags but I am receiving empty strings for the values.
The length of the list of allChatTags is 2, which should be 4.
I have no idea what is going wrong, can someone tell me what is happening?

My blocks:


Here you can also see the Do it result:

Instead of setting project bucket, set URL and try.

Click on chats, copy that URL, using this URL get tag list under chats.

When tag list got value
Use for each item in list : get value
Firebase db Get value

And also, create a test project to check whether the values are getting or not by using a label and set label test to get value.

2 Likes

Is this block for to get values under chats?

If yes, then for each item in list : here set get value

1 Like

I think the problem is here.

You are storing tags(which is a list) as a single item but retrieving them as list.

2 Likes

Try this
blocks

1 Like

So what should I do there?

Thanks for your reply. I tried doing that but it shows me empty string again for the messages but this time the values of chat tags of the bucket 9198508* * * * 6 are coming but still empty string for the 9187449* * * * 0 chats. Here is the Do it result.

And also for

I tried calling values by URL. The result is still same but the values of ChatTags are changed and they are showing me the last 2 values of chat tags which are inside the 9198508* * * * 6 bucket, but empty string for 9187449* * * * 0.

I think when you use for loop to get values, add items to list is the correct block as it returns the values one by one.

If you will look at tag list carefully then you will find that firebase returns a list of lists so something is in wrong with project bucket or database structure.

1 Like

I have set the project bucket to empty in the Firebase properties and also I tried changing my database structure, also deleted some extra things but still the result is same every time. At first I thought that there is a problem because of the special characters which I used in the chat tag, but I manually tested the Get Value block for the same tag and it was just working fine.

As you guys can see there is now only 1 bucket in my Friends List which is 9187449 * * * * 0 means there is only 1 friend in the friends list.

Now I tried to get the values and I got the chat tags and their values without any problem.

**The problem only occurs when there are more than 1 buckets in “FriendsList” bucket and it returns empty string for the first bucket which is 9187449 * * * * 0 and it returns me the values of the last bucket. How can I fix this issue? This problem does not occur when there is only 1 bucket in the ‘FriendsList’.

Try using seperate firebase db components for each item to get values.

1 Like

Yes I am using 2 Firebase components. One to get the tag list of the phone numbers in my friends list. And another for getting the tag list of the ‘Chats’ bucket. But still the result is same. I am experiencing this issue first time.

One more suggestion, remove Chats bucket.

Add Tags and values under chats directly to phone numbers.

Now get tag list as phone numbers.

When tag list got value
For each item in list : get value
Firebase db Get value

1 Like

Okay I will try this and let you know. Thank you
Btw I don’t want to just store the chats, but also other information about the user like his profile picture, last seen, etc…So if I removed the Chats bucket and store the chats of the user directly inside the phone number, how will I know which are the chat tags and which are the rest things? Because the chat tags contain date and time when message is sent and the username.

Ohh okay.

By the way, by using firebase URL and project bucket in proper way according to the need we can get every tag and every value from firebase.

But you have to find out that logic, by trying in different ways.

1 Like

Don’t set token and url at a one place. Set them according to the requirements, where you using firebase get taglist or get value.

Also, check this project bucket logic result text that u set by joining text blocks, by using a label.

Set label text to : same joining text logic.

1 Like

Hello, the result is still the same (empty string). But I am receiving values for the second bucket successfully which is under the 9198508 * * * * 6 bucket. But receiving empty string for the bucket 9187449 * * * * 0.

I did exactly as you said. Here are the blocks:


Do It Result:

See here I got the value for the second bucket which is 9198508 * * * * 6 and empty string for first bucket which is 9187449 * * * * 0.

:point_down:

You can also see result of the Firebase URL. This result is generated in the end after the Firebase_Database2 Got Value block.

:point_down:

Hello. I have this same problem and I can’t solve it.

I tried to go through the tags with a for, but I can’t get the contents of a specific tag inside a single bucket.

Did you manage to solve this problem? How did you solve it?
Thank you.

Show your block

1 Like