samedi 2 septembre 2017

fire base is retrieving null values

i am working on a web app that uses fire base here is my java script code :

<script src="http://ift.tt/2w74lZn"></script>
<script>
  // Initialize Firebase
  var config = {
    apiKey: "AIzaSyCuG09M2Z10h-sVz3n0tu-lzcNzspiZM5o",
    authDomain: "actfirebase.firebaseapp.com",
    databaseURL: "http://ift.tt/2gBYE0B",
    projectId: "actfirebase",
    storageBucket: "actfirebase.appspot.com",
    messagingSenderId: "1024677586041"
  };
  firebase.initializeApp(config);


var rootRef = firebase.database().ref().child("news");

rootRef.on("child_added", snap => {

var name = snap.child("news1").val();
var name2 = snap.child("news2").val();

document.getElementById("fnews").innerHTML = name;


});



</script>

and her is the html

<section class="news" id="news" style="opacity:0.01;">
        <h3 style="text-align:center;">Latest news</h3>
        <article id="newses">

            <h2 id="fnews">this is the standers text.!!!</h2>
        </article>
        <article>
            <div id="news21" class="info" style=" text-align:center; width:98%;" >
                <h4 Style="color:#ffffff;">Omnis iste natus error </h4>
                <p id="news22" style="color:#000066" >Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores (...)</p>
            </div>
        </article>

        <h4 style="color:#ffffff; text-align:center; "><a href="#" style="color:#ffffff;">ARCHIVED NEWS</a></h4>


    <!-- / container -->
</section>

my problem is that when i launch the app the text changes from this is the standers text.!!! to NULL

i don't know what the problem is please help me

thanks in advance.

Aucun commentaire:

Enregistrer un commentaire