I want to make an order by child but it does not work with firebase

0

my javascript

 var referencia = database.ref("news").orderByChild("fecha");
var news = {};

referencia.once('value')
    .then(function (snapshot) {
        news = snapshot.val();
        console.log(news);
        var newsBlog = document.getElementById("newsBlog");
        var newsB = "";
        for (var key in news) {
            console.log(news[key]);
            newsB += '<div class="mb-5">';
            newsB += '<div class="media">';
            if (news[key].customFileLangBlog == 'NONE')
                newsB += '<img alt="Sin Fotografía"/>';
            else
            newsB += '<figure class="figure">';
            newsB += '<img src="' + news[key].customFileLangBlog + '" width="300" height="300" class="figure-img rounded mr-3" alt="">';
            newsB += '<figcaption class="figure-caption text-center">' + news[key].fecha + '</figcaption>';
            newsB += '</figure>';
            newsB += '<div class="media-body">';
            newsB += '<h5 class="mt-0"><a href="noticias.html">' + news[key].title + '</a></h5>';
            newsB += '<h6 class="texto" id="textContenido">' + news[key].subContenido + '</h6>';
            newsB += '<a href="noticias.html" class="btn btn-sm btn-danger">Leer mas...</a>';
            newsB += '</div>';
            newsB += '</div>';
            newsB += '</div>';
            newsB += '<hr>';
        }
        newsBlog.innerHTML = newsB;

    });

I'm painting it in the html but I'm not sorted by date

    
asked by ivan fuenmayor 19.12.2018 в 16:23
source

0 answers