nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
641 stars 98 forks source link

Storage with nuxt module gives Cannot read property 'delete' of undefined after deleting the file #500

Closed Amr2812 closed 3 years ago

Amr2812 commented 3 years ago

Version

@nuxtjs/firebase: ^7.5.0 firebase: ^8.3.1 nuxt: ^2.14.6

Steps to reproduce

Nuxt Running in SPA mode (No Server Side Rendering) with target static, the problem is it does delete the file then gives me the Error: Cannot read property 'delete' of undefined so the rest of the async function doesn't complete!

My Function:

async deleteFunction () {
try {
        this.deleteLoading = true;

        await this.$fire.storage
          .ref("CVs/")
          .child(this.$store.state.auth.user.uid)
          .delete();

        await this.$fire.firestore
          .collection("users")
          .doc(this.$store.state.auth.user.uid)
          .update({
            cv: this.$fire.firestore.FieldValue.delete(),
          });

        this.cvLink = null;

        this.deleteLoading = false;

        this.$notifier.showMessage({
          color: "success",
          content: "Current CV Deleted Successfully",
        });
      } catch (err) {
        this.$notifier.showMessage({
          color: "red",
          content: err,
        });

        this.deleteLoading = false;
      }
    },

}

What is Expected?

Deletes the file without errors

What is actually happening?

Deletes the file and gives error: Cannot read property 'delete' of undefined

Amr2812 commented 3 years ago

Solved: Discovered that the error was from the firestore delete because I had to use $fireModule instead of $fire