Reputation: 87
I have an ionic app trying to update the records in firebase. I keep on getting this error. Not sure what I am doing wrong.
Error: Uncaught (in promise): FirebaseError: [code=invalid-argument]: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: a custom Object object
FirebaseError: Function CollectionReference.doc() requires its first argument to be of type non-empty string, but it was: a custom Object object
this is my update function.
updateTodo(todo: Todo, id: string) {
return this.todosCollection.doc(id).update(todo)
}
Upvotes: 4
Views: 21051
Reputation: 488
In my case I was passing a number type variable in the .doc function but it requires a string. Verify that your "id" variable has a value and it is not undefined, null or and empty string.
Upvotes: 1
Reputation: 97
I had this problem and solved it by typing .doc(cred.user.uid) instead of .doc(cred.user.id).
Upvotes: 0
Reputation: 2720
Go where you're calling that function updateTodo use uid instead of id.
Upvotes: 0
Reputation: 77
The problem is on the id that you are passing in doc,it is supposed to be a string..try logging its value just to check what you are exactly passing
Upvotes: 0
Reputation: 151
This happens when you are trying to send an empty object to firebase. I had this error when I reset my form values before the async call could finish..
Upvotes: 1