This is my Firebase Database:
I need the URLs of the images that are associated alongside the unique random name generated by the push method. Is there any way I could do that? Also, there must exist a better way of sending data. Please, let me know. Thanks.
imgRef.on('value', function(snapshot) {
console.log(snapshot.val());
});
This is, as expected, returning the entire JSON object. I need the URL.
This is the most basic way to show the list of image URLs:
var rootRef = firebase.database.ref();
var urlRef = rootRef.child("user1/DAA Notes/URL");
urlRef.once("value", function(snapshot) {
snapshot.forEach(function(child) {
console.log(child.key+": "+child.val());
});
});
[enter image description here][1]
[1]: https://i.stack.imgur.com/MYaWa.png
readUserData = async () => {
try {
this.setState({ loading: true });
await firebase
.database()
.ref("recette")
.once("value", function (snapshot) {
snapshot.forEach(function (child) {
console.log(child.key.total + ": " + child.val());
});
});
} catch (e) {
// Error! oh no
} finally {
this.setState({ loading: false });
}
};
I want to get the value of total the child.key.total is undefined: [object Object] while child.val()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.