2

I am using GeoFire to get nearby locations then using the keys to get a database reference and then trying to push that data into a array, but can't get it to work. Any help would be sweet :)

let myArray = []
  var database = firebase.database(); // Ref to Firebase Database
  var geoFire = new GeoFire(database.ref('items_locations'));
  const lat = location.coords.latitude;
  const long = location.coords.longitude;
  let radius = 5
  let center = [lat, long];
  let geoQuery = geoFire.query({
      center: center,
      radius: radius
  });

  geoQuery.on("key_entered", (key, location, distance) => {
      let markers = firebase.database().ref(`items/${key}`).orderByKey();
      markers.on('value', (snapshot) =>{   
          let name = snapshot.child("name").val()
          myArray.push(name`enter code here`)
      })
   })

getting a empty array

KENdi
  • 7,576
  • 2
  • 16
  • 31

0 Answers0