1

My JSON format is

    {
      "Featured" : {
        "project" : [ {
          "artist" : "stuff",
          "artistEPK" : "artistsownepk.pdf",
          "author" : "john queue author",
          "date" : "7/28/2016",
          "fullScreenImg" : "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687",
          "linksToMedia" : [ "" ],
          "linksToPress" : [ "" ],
          "location" : "10 Main Street",
          "mainImg" : "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687",
          "pressImgs" : [ "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687" ],
          "pressRelease" : "projectpressrelease.pdf",
          "projectImgs" : [ "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687", "https://firebasestorage.googleapis.com/v0/b/wallplay-a8440.appspot.com/o/Screen%20Shot%202016-06-08%20at%2012.00.06%20PM.png?alt=media&token=1df5d60d-808c-48bb-a591-e005f82e4687" ],
          "projectSubheader" : "subheader of project",
          "projectTitle" : "title of project",
          "projectURL" : "",
          "soundFile" : [ "" ],
          "text" : "here there would be a text for james turell",
          "videoURL" : "www.youtube.com/james-m-video"
        } ]
      }
    }

So when I go into my Firebase and try to pull my information using

var ul = document.getElementById("featured_links");

    featuredRef.orderByChild("date").on("child_added", function(snapshot) {
        console.log("inside ref");
        var links = snapshot.val().fullScreenImg;
        var li = document.createElement("li");
        var img = document.createElement("img");
        img.setAttribute("src" , links);
        li.appendChild(img);
        ul.appendChild(li);

        console.log(links);

});

where featured-links is just a ul in my html file that I'm trying to put in. This new JSON format is a lot bigger than my other one, but the other one didn't have a problem with reading the files in.

Other JSON:

{
  "Featured" : {
    "Link2" : {
      "isEmbed" : false,
      "priority" : 4,
      "tag" : "yahoo people",
      "url" : "https://s3.amazonaws.com/hagshs8282n23/image7.jpg"
    }
  }
}

As far as I can see, featuredRef.on("child_added", function(snapshot){ is NOT a for loop, since it's not printing "inside ref" when it reaches it. At the moment there's only one data entry inside so I don't know why I'm having such a problem with it.

Homerdough
  • 353
  • 1
  • 3
  • 12
  • I'm not really clear on what your problem is. It'll be a lot easier to help when we can easily see the problem in front of us. Can you set up a *minimal* jsbin/jsfiddle that reproduces the problem? – Frank van Puffelen Jul 29 '16 at 18:47
  • One quick check you can do is add an extra callback to your code to see if the listener is erroring out: `featuredRef.orderByChild("date").on("child_added", function(snapshot) {...}, function(error) { console.error(error); })` – Frank van Puffelen Jul 29 '16 at 18:48
  • https://jsfiddle.net/r44y6a9L/5/ here you go – Homerdough Jul 29 '16 at 20:16
  • If you add the error handler I suggested, you will see that you don't have read permission on the node:`Error: permission_denied at /Featured/project: Client doesn't have permission to access the desired data.(…)`. See http://stackoverflow.com/questions/37403747/firebase-permission-denied – Frank van Puffelen Jul 29 '16 at 20:44
  • I saw that and dealt with it but no difference. I fixed it again for you, so it should work now. I still don't see my image coming up though – Homerdough Jul 29 '16 at 20:48
  • Please run the fiddle and check the JavaScript console of your browser: `Uncaught TypeError: Cannot read property 'appendChild' of null`. Unless the jsfiddle reproduces the problem you are having, it is not of much use. – Frank van Puffelen Jul 29 '16 at 20:56

0 Answers0