Skip to content
Advertisement

Getting the Data in snapshot.val() but not able to treat it

I was making an app and had to fetch data from Realtime Database. I am getting the data in snapshot.val() like this

JavaScript

And Now I want to access this data. When I am trying snapshot.val()[0].email and
snapshot.val().[0].email I am Getting

JavaScript

So, I am working in React Native and this is the code

JavaScript

The nodes of database are as follows: enter image description here

Please help me out.

Advertisement

Answer

While the approach in Dharmaraj’s answer works, I recommend using Firebase’s built-in forEach operation, since that ensures that you process the results in the same order the database returns them:

JavaScript
Advertisement