K
K
kiddle2020-06-08 18:05:43
JavaScript
kiddle, 2020-06-08 18:05:43

firebase how to get data in js?

Hello I am trying to get data from Firebase. I get the data, but I can't do anything with it.
Here is the data I am getting Data Retrieval
5ede5305443b2597523125.png
Function

function readdata() {
    var data = [];
    firebase.database().ref("/polygons/").once("value", function(polygons) {
        polygons.forEach(function(p) {
            data.push([p.val().color, p.val().email, p.val().polygon]);
        });
    });
    return data;
}

The catch is this, I write the data to an array, which means that you can access each cell by index, but when you try, I get undefind .

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question