I'm currently using a Firestore backend. What I want to achieve is to update a document on Firestore when the window closes. I know we could use Navigator.sendBeacon() to call an API when a window closes because it receives url and data (optional) as its parameters. However, I want to instead execute a function, for example from Firestore, there is a function called updateDoc. Is there a way I could achieve this?
Or is there any other approach I could use?
According to this Documentation :