1
Currently I use this function to read data from firebase database:
function ler() {
database.ref(referencia_database).orderByChild('nome').once('value').then(function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var chave = childSnapshot.key
var obj = childSnapshot.val()
//Verifica se a imagem existe no storage, se sim usa ela, se não usa a padrão
storage.ref(chave).getDownloadURL().then(function(url) {
mostrar(chave, obj.nome, url)
}).catch(function(error) {
mostrar(chave, obj.nome, './image/default.png')
});
})
})
}
The problem: because of the checkpoint whether the image exists in the (asynchronous) Path, the data is displayed randomly.
How to solve this?
I do not save anything from the image in the database (Realtime database), take the image by the name of the file that is the same as the object key, it is better to change to how you showed?
– Costamilam
Yes, that’s my suggestion.
– Rosário Pereira Fernandes
Okay, but I want only one image to be registered for each object, and I’ll organize Storage like this:
/chave/nome_receita.png
, can tell me how to delete the images from one directory and set another, regardless of the name, since the user can change the image and the file name will probably be different– Costamilam