I'm trying to read all data from my firebase but I canno do this
Here is my code:
firebase.database().ref().child('users/').on('value',function(snapshot) {
window.alert(snapshot.val());
});
and my firebase look like this:
"users":
{
"uid": {
"username": "AAA",
"email": "aaa@a.com"
},
"uid": {
"username": "ZZZ",
"email": "zzz@z.com"
}
}
I can't get anything data using this code
update
I have defined my security in firebase
{
"rules":{
"users":{
"$uid": {
// grants write access to the owner of this user account whose uid must exactly match the key ($uid)
".write": "auth !== null && auth.uid === $uid ",
//".write": "auth !== null && (auth.uid === $uid || auth.uid ==='0127a226-83ec-4eae-bbc7-53b81da10c0d')",
// grants read access to any user who is logged in with an email and password
".read": "auth !== null && auth.uid ===$uid "
//".read": "auth !== null && (auth.uid ===$uid || auth.uid ==='0127a226-83ec-4eae-bbc7-53b81da10c0d')"
//".validate": "newData.hasChildren(['full_name','uid','state_light'])"
}
}
} }