I am using vue.js version 2 with cdn mode. I have created 2 vue components. One components is pushing the data to database and the other component will show it. Below is the code
firebase.database().ref().on('value', function (data) {
console.log("called");
console.log("data received " + JSON.stringify(data));
});
I want to read data continuously, but above method is not working. It reads the data only one time. How to solve this issue so that I can read the data continuously ?
I have done this in vue like this
import { onValue, ref as Ref} from "firebase/database";
onValue(Ref(db, path), (snapshot) => {
// you get value here
//snapshot.val());
});
// where db is the main Database reference
// and path is the path inside db