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

208
Visualizações
error when deleting storage data if data don't exists when using deleteObject(storageRef)?

I am creating a delete user data function. One part of this function is to clean storage. If the user don't have an image to begin with, an error is generated halting the exception of the rest of the function, how to prevent this error form happening, without having to check and make a get request to see if there is data in storage to begin with ?

Error message : Object 'profiles/id' does not exist. (storage/object-not-found)

// Delete user's Storage Data
const storage = getStorage();
const storageRef = ref(storage, `profiles/${currentUser.uid}`);
await deleteObject(storageRef);
// Delete the user 
await deleteUser(currentUser);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As mentioned by @JohnHanley, you can use exception handling and catch the error.

See sample code below on how to implement exception handling:

const storage = getStorage();

const storageRef = ref(storage, `profiles/${currentUser.uid}`);

await deleteObject(storageRef).then(() => {
    console.log("File deleted successfully!")
  }).catch((error) => {
    // Do something if error occured.
    if (error.code == 'storage/object-not-found') {
        console.log('Object not found!')
    }
  });
// Delete the user 
await deleteUser(currentUser);

You can refer to this documentation for other available error messages.

about 4 years ago · Juan Pablo Isaza Relatório
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