I know this is very simple question, but I can't find out a simple answer anywhere.
I start messing around with Firebase, and I want to just get all information of user then paste it where I need in my app.
For example, I have Database, inside I have "Users" - then keys (like -KjVkK3QCAXxMCfdyROe
) and then all the info (name, age, job...).
What I come out until now is:
let app = Firebase.initializeApp(config)
let db = app.database()
let usersRef = db.ref('Users')
Then in my vue app component -
firebase: {
users: usersRef.child('-KjVxBYyKv3_PFLavId3')
},
Now I want to know how to get the name, age, job values? I tried this.users.name
- but it is undefined.
I looked and found that code, but it too long and not efficient:
this.users.on("value", function(snapshot) {
var username = snapshot.val().name;
});
Please give hand and help me understand how can I get to the object and get the info simple like regular object. How can I turn Firebase Reference into simple Object?