Closed marcoshuck closed 6 years ago
hello @marcoshuck
Well, as mentioned in the log, you need to audit the usage of the dates, because timestamps stored in Cloud Firestore will be read back as Firebase Timestamp objects instead of as system Date objects.
Basically, you should add timestampsInSnapshots
parameter into the Firestore.
import Firebase from '@firebase/app'
import '@firebase/firestore'
import config from './config'
const firebaseApp = Firebase.initializeApp(config, {
timestampsInSnapshots: true
})
const api = firebaseApp.firestore({timestampsInSnapshots: true})
export default api
Finally, In your component, don't forget to parse the timestamps timeStamps.toDate()
Thanks!
Hello @amranidev, thank you for your help.
I have solved the problem making changes on api.js as you suggested.
This is what I did, and it's working fine right now. Note that I'm not longer passing the settings through initializeApp() neither firestore(), I'm doing it on the settings() method as firebase suggested on the console log. For a weird reason this wasn't working last night.
import Firebase from '@firebase/app'
import '@firebase/firestore'
import config from './config'
const firebaseApp = Firebase.initializeApp(config)
const api = firebaseApp.firestore()
api.settings({timestampsInSnapshots: true})
export default api
This Worked liked charm for mine after some pieces of struggle, Thanks @marcoshuck I borrowed alot from your post
import firebase from '@firebase/app' import 'firebase/firestore' import firebaseConfig from './firebaseConfig' const firebaseApp = firebase.initializeApp(firebaseConfig) export default firebaseApp.firestore() const api = firebaseApp.firestore() api.settings({timestampsInSnapshots: true})
In my firebaseInit.js file I changed it to this and its very awesome now
In my firebaseInit.js file I changed it to this and its very awesome now
import firebase from '@firebase/app' import '@firebase/firestore' import firebaseConfig from './firebaseConfig' const firebaseApp = firebase.initializeApp(firebaseConfig)
const api = firebaseApp.firestore() api.settings({timestampsInSnapshots: true}) export default api
Glad it works 👍
Hi there, I want to share this error I have been getting when I try to test my firestore with my vuejs app
Console log
api.js
main.js
The view renders but there is no content from firestore.
Hope you can help me!!
Greetings from Argentina.