Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
How to catch a Firebase Storage error when the file doesn't exist?

My react app displays an image if it exists in Firebase Storage:


import firebase from 'firebase/app';
import 'firebase/storage';

//...//

const [imageUrl, setImageUrl] = useState(null)

//..//

firebase
  .storage()
  .ref('path_to_image')
  .getDownloadUrl()
  .then((v)=>{setImageUrl(v)}) //This sets the imageUrl state. I still get the error even if I remove this line
  .catch(()=>{setImageUrl(null)}

But I still get a 404 error logged in the console:

GET http://.../v0/....appspot.com/o/userPhotos%2FJfYvcUGG8LkyNwyu1dKpJr6j4EKmE 404 (Not Found)

I tried wrapping everything in a try/catch, but the error still gets logged.

How can I catch the exception, or is there a way I could verify that the file exists before calling getDownloadUrl?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda