D
Well, after a good night's sleep waking up from 30 in 30 minutes with the same question in mind, I decided to return use the firebase callback just to treat the data and I did the part of rescuing the images out of this callback. The beginning solves the problem of returning the props before the promises are resolved, but I still do not know what the reason for async/await not having worked as I would like. From what I understand, the block await realtime.ref().onde('value', async snapshot => {...} ) does not expect all promises to resolve and the code continues to run on the line immediately after that block, that is, in return {props}.Although I do not understand what happened, this was my solution to the problem:// após o calback da função once do firebase, quero que todas as url estaticas do google sejam tranformadas em urls do dominio firebasestorage.googleapis.com
try {
// Pega url atual da imagem no Firestore e armazena no mesmo local que antes tinha apenas uma url estatica do google, "gs://..."
console.log( 'Veio até aqui' )
const vetPromise = await criarArrayDePromisesDasImagens( produtos )
produtos = await Promise.all( vetPromise ).then( ( values ) => { // resolve todas as promisses e então coloca o resultado das imagens no produto
const result = porAsImagensNosProdutos( values, produtos )
console.log( 'Imagens resgatadas, promise sucess' )
return result
} )
console.log( 'produtos promise all =>', JSON.stringify( produtos, null, 4 ) )
} catch ( error ) {
global.console.log( 'erro ao capturar promises => ', error )
}