Is not Firebase allowed to use get and set in query information?

2

I'm trying to use the get and set methods with javascript in the firebase querys ..

It does not allow me to use get () because it does not access the array and gets error or lenght 0.

Why does this happen and how should it be done?

Sample code:

// BUSCAR NO FIREBASE
function getMarkersFB(){
    let arrMarkers = new Array();
    let databaseROOT = firebase.database().ref('aliansce/maps/');
    databaseROOT.on('child_added', (mapsKeys) => {

        let databaseMAPS = databaseROOT.child('' + mapsKeys.key + '/markers/');
        databaseMAPS.on('child_added', (markersKey) => {

            let databaseMARKERS = databaseROOT.child('' + mapsKeys.key + '/markers/' + markersKey.key);
            databaseMARKERS.on('value', (markersChildsKeys) => {
                //console.log(markersChildsKeys.val())
                arrMarkers.push({
                    id: markersChildsKeys.val().markerID,
                    points: markersChildsKeys.val().markerPoints,
                    title: markersChildsKeys.val().markerTitle
                });

            });
        });
    });

    setMarker(arrMarkers)
    console.log(getMarker())

IfIgivethefollowingcodeitdoesnotfindsuchvalue,outsidethefirebasefunction.

console.log(getMarker()[0].id)

    
asked by anonymous 05.01.2018 / 14:35

0 answers