I am developing firebase webapp and faced one problem. I cannot access(read/write) firebase realtime database.
<script src="https://www.gstatic.com/firebasejs/4.12.0/firebase.js"></script>
<script>
var config = {
apiKey: "AIzaSyCPYu_iqHjNoXjMfdMVLoYs5Graf2gdz7I",
authDomain: "sharing-is-caring-967c8.firebaseapp.com",
databaseURL: "https://sharing-is-caring-967c8.firebaseio.com",
projectId: "sharing-is-caring-967c8",
storageBucket: "sharing-is-caring-967c8.appspot.com",
messagingSenderId: "884406512169"
};
firebase.initializeApp(config);
firebase.auth().signInWithEmailAndPassword("[email protected]", "Qqqq123").then(function(info) {
var uid = info.uid;
firebase.database().ref('users/' + uid + '/userDetails').once('value').then(function(data) {
alert(data)
}).catch(function(error) {
alert(error.message);
});
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
alert(errorMessage);
// ...
});
</script>
SignInWithEmailAndPassword work fine. And At database part, once('value') function does not response anymore. There is no success and no fail. There isn't any error message and always silence
Rules of Realtime Database
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"threads": {
"$tid": {
"messages": {
".indexOn": ["read", "date"]
}
}
}
}
}
Fire base Web Setup Guide Screenshot of my Firebase
Database structure
{
"users" : {
"BzucCBivhiRUogK5GeNrMV6k6M83" : {
"userDetails" : {
"displayName" : "Stanislav Sergeev",
"email" : "[email protected]",
"notifications" : true,
"phoneNumber" : "",
"profile_image" : "",
"pushToken" : "ec7iJ7Mt7Lg:APA91bFb8NK2XeaLVUgr-DEPRFuLMDCk9_tIr_eHBjmuZPnHDUvFuCsj3kez4F5-Y9CjVXOY6VlsFi5nlazSZys4KBjwCKcpINbV5S2ZEaH09aWZ6sLga8dOja-UIp3Iz3DSOAb4bcH4"
}
}
}
}