I have a function that gets data from Firestore, but always return undefined. I had previously used .get() method, but I want my data to be auto-updated when the database gets some new data.
I know that .onSnapshot() doesn't return a promise, so using asynchronous is not an option.
getdata = (dbRef) => {
dbRef.onSnapshot(snapshot => {
console.log(snapshot);
return snapshot;
});
}
The log display the snapshot in the console, but when I call that function, it returns undefined