Greetings. I am currently developing a page whose function is to recover data from Firebase. During the tests, when establishing the reference for obtaining the data, if I establish it in a fixed way it works without problem. But assigning a value dynamically through a variable, throws the following error in console:
-Uncaught TypeError: Can not read property 'length' of null at Function.each
This is the code:
firebase.initializeApp(config);
var encuentra = $(producto).val();
var database = firebase.database();
var referencia = database.ref(encuentra);
var reportes={};
referencia.once('value', function(datos)
{
reportes=datos.val();
$.each(reportes, function(indice,valor){//muestra datos}
Setting ref () as: database.ref ("product") does not present a problem, it works properly; but using the variable finds , which contains the value of a input: text seems to cause a null result or some inconsistency when accessing the data. Any ideas?
Beforehand, thank you.