'Error when creating or overwriting a document in firebase
I am trying to add user or overwrite the user document in case the user already exists but I am getting this error:
FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore
What am I doing wrong?
import { auth, db } from "../firebase"
import {doc, setDoc} from 'firebase/firestore'
import { useEffect } from "react";
unction MyApp({ Component, pageProps }) {
useEffect(() => {
if(user){
setDoc(doc(db, 'users', user?.uid), {
email : user.email,
lastSeen: firebase.firestore.FieldValue.serverTimestamp(),
photoURL : user.photoURL
}, {merge: true});
}
}, [user])
}
export default MyApp
Solution 1:[1]
i was using the firebase v8 to call the serverTimestamp() method v8 module
firebase.firestore.FieldValue.serverTimestamp()
v9 module
serverTimestamp()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Emmanuel uzoezie |
