nuxt-community / firebase-module

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

@firebase/firestore: Firestore (8.10.0): INTERNAL UNHANDLED EERROR: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined #586

Open macketplace opened 2 years ago

macketplace commented 2 years ago

Hello,

I am using a nuxt application to try and access my firebase firestore. I have a collection named 'messages' and a document named 'message'

In plain javascript it is very simple what I am trying to do. I just want to grab the data within the document message and be able to update or write to it if needed. But every time I try to access the data within a document or a collection.. I get the same error:

@firebase/firestore: Firestore (8.10.0): INTERNAL UNHANDLED ERROR: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

image

// The following code works and shows me the id of the document
const messageRef = await this.$fire.firestore.collection('messages').doc('message')
    try {
            const message = messageRef.id
            console.log(message)
    } catch (e) {
            console.log(e)
            return
    }
}

// However as soon as I try to get, set, or update the document I get the error..
const messageRef = await this.$fire.firestore.collection('messages').doc('message')
    try {
            const message = await messageRef.get() || messageRef.set({ foo : 'bar' }) || messageRef.update({ foo : 'bar' })
            console.log(message)
    } catch (e) {
            console.log(e)
            return
    }
}

It is important to note for this project that Auth service is working just fine and I can do CRUD operations using the this.$fire.auth module.

Any help to figure this out would be greatly appreciated.. thank you!

Here is my firebase config and nuxt modules config

const firebaseConfig = { apiKey: process.env.NUXT_FIREBASE_API_KEY, authDomain: process.env.NUXT_FIREBASE_AUTH_DOMAIN, databaseURL: process.env.NUXT_FIREBASE_DATABASE_URL, projectId: process.env.NUXT_FIREBASE_PROJECT_ID, storageBucket: process.env.NUXT_FIREBASE_STORAGE_BUCKET, messagingSenderId: process.env.NUXT_FIREBASE_MESSAGING_SENDER_ID, appId: process.env.NUXT_FIREBASE_APP_ID // measurementId: '' }

['@nuxtjs/firebase', { config: firebaseConfig, services: { auth: true, firestore: true, storage: true } }]

simeon9696 commented 2 years ago

Your await should be in your try catch statement.

Your messageRef is a reference to your actual message document. It's not an operation to be executed or to be awaited

Wherever you call .set and .get etc is where your await should be

const message = await messageRef.get()

macketplace commented 2 years ago

I forgot the await on that line... but with or without it, the same error occurs. I even downgraded firebase sdk and still same issue. @simeon9696