[Chartjs]-Dynamically populate array with Firebase Data Vue.js

2👍

db.ref('school') returns a ‘firebase.database.Reference’ object you have to retrieve the data from it. you could add this to your vue mounted lifecycle hook:

db.ref('school').once('value')
 .then((dataSnapshot) => {
   this.schoolsArray = dataSnapshot.val();
 });

you could also use the .on method which will automatically fire your callback each time when the data changes on the server. so make sure you remove that when the component is destroyed.
for documentation see: https://firebase.google.com/docs/reference/js/firebase.database.Reference#once

Leave a comment