I want onSnapshot to fail if there is a failed internet connection (getting user record - if none is found I set up a new one).
I see
onSnapshot(doc(db, 'users', userAuthData.authUser.uid),
{ source:'cache'},
(returndoc) =>{...})
but when I change 'cache'
to 'server'
I get no overload matches this call
Any advice? Source for options
documentation?
That error message is correct: the source
option is of type ListenSource
, which can only be 'default'
(server and local) or 'cache'
(local only). There is no way to only listen for updates from the server.
The only call that does what you want is getDocFromServer()
. Alternatively, you can attach a default snapshot listener, and ignore snapshots where metadata.fromCache
or metadata.hasPendingWrites
is true
.