Reputation: 692
I am struggling with a simple JSON from Firebase and I am trying to access the value inside it. But can't seems to wrap my head around, I am trying to access the apiHash and apiId. Any help will be great! Thanks
This is the json retuned by Firebase.
Mv9ALVaVEwa0nGyYWeo:{
apiHash: '6962d35961356a5',
apiId: 9506201
}
The code to get the json above
async function queryData(_mobileNo){
const ref = admin.database().ref("users/");
const snapshot = await ref.orderByChild("mobileNo").equalTo(_mobileNo).once('value');
return snapshot.val();
}
The Firebase realtime data structure
Upvotes: 0
Views: 24
Reputation: 50830
You can try using Object.values()
as shown below:
// data = snapshot.val()
const data = {
randomKey: {
apiHash: "value"
}
};
console.log(Object.values(data)[0]);
Upvotes: 1