Firebase GET speed

I’m trying to speed up this loop to retrieve Firebase data:

It takes about 2.5 seconds to complete the loop.

I tried assigning an app variable to the data to avoid repeatedly accessing Firebase:

The loop now takes less than 0.25 seconds but it’s not retrieving the data correctly. I’m unsure how to reference something like Homeooms/4Y/Students using a “get property of object” block. I thought I had it right but clearly I don’t.

This is the Firebase data structure:

I’m using my own post as a reference point: Firebase retrieval speed test - #7 by tatiang

1 Like

Yes, I always get into this trap. The get object properties of block generate a single level list and therefore the j loop variable is just a simple text entry of the key name (1B, 1C, 2B, …) without any data under it. It is not an object anymore, This is why you cannot get any property from it. so this
evaluates to null.

1 Like

Yes, good point. I hastily made that second attempt this morning. I need to rethink how I’m going to access the data without multiple Firebase calls.

1 Like

The issue with this code is that you want to mix between two different way to refer to properties in an object.

Use a get property inside a get property and it should work.

get property students of get property j of homerooms

That worked! Thank you, @muneer! :pray:

And it only takes 0.2 seconds now.


@tatiang , I have to apologize. I advised to add a second get property block while it was easier to change the join text block you were using from /Students to .Students which should work with a single get property block.

It’s 3am where I am so I’m not in my clearest of mind.

1 Like

Ah, yes, I was so wrapped up in Firebase paths that I was using / but now I recall that . should work well. I’ll try that. Thanks again.

Yes, that works too:

1 Like

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