Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@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 this issue Oct 2, 2021 · 2 comments

Comments

@macketplace
Copy link

macketplace commented Oct 2, 2021

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
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants