Back

File is being deleted but i can't get a Success or Error code after deleting a file

  • 0
  • Web
  • Cloud
Fulton
27 Jun, 2024, 21:10
TypeScript
export const deleteProfileImage = async (fileId) => {
  try {
    const result = await storage.deleteFile(
      process.env.PUBLIC_USER_IMAGES_ID, // bucketId
      fileId // fileId,
    );

    console.log('deleting...',result);
    await updateCurrentDocument({
      profileImage: "",
    });

    if(result){
        return { success: "image supprimée" };
        
    }else{
        return { error: "Une erreur s'est produite. Veuillez réessayer" };
        
    }
} catch (error) {
    console.log(error);
}


}; 
TL;DR
Problem: Developer is not receiving a success or error code after deleting a file. Solution: Check if the `result` after deleting the file is being properly retrieved. Update the logic to handle the success or error cases accordingly.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more