Accessing snapshot.val() key

Hello there,
sorry if the title is not good enough to describe the situation here.
anyhow, am trying to access values inside an object retrieved using

.once('value',function(snapshot) {

the object retrieved as follow:

when i access snapshot.val() i get it as the picture when i try to access the type for example
snapshot.val().type its undefined,
i think i have to go through snapshot.val().(key).type
and since its random key generated by firebase in insertion how can i access the value?

var key = Object.keys(snapshot.val())[0] //Array of the keys (hope it's only one always)

var type = snapshot.val()[key].type
1 Like

@felix9607 thank you very much for your reply,
I’ve found another solution as follow:

let item = Object.getOwnPropertyNames(snapshot.val());
let value = snapshot.child( item[0] as string).val();