gauravsharma0190
Posts: 125
Joined: Tue Oct 28, 2014 6:36 am

Display data from Firebase database in a HTML page

Mon Sep 02, 2019 12:10 pm

vanet firebase.png
database structure
vanet firebase.png (17.99 KiB) Viewed 910 times
vanet firebase.png
database structure
vanet firebase.png (17.99 KiB) Viewed 910 times
Hello there,
i am working on firebase realtime data base from which i want to use those data on my web page.
here is my code. As i can get it from my console but how can i get it on my html web page

Code: Select all

<head>
    <meta>
    <title>VANET REALTIME DATABASE ></title>
    <script src="https://www.gstatic.com/firebasejs/6.5.0/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/6.5.0/firebase-database.js"></script>
</head>

<body>
    <!--value -->
    <pre id="node1">
           </pre>
    <!--Child -->


    <script>
        window.onload = function() {
            // Initialization Firebase
            const firebaseConfig = {
  [b]  apiKey: "[/b] *************API KEY*********",
   [b] authDomain[/b]: "**********.firebaseapp.com",
    [b]databaseURL[/b]: "https://vanet-6d0a3.firebaseio.com",
  [b]  projectId: [/b]"*********",
    [b]storageBucket:[/b] "*********.appspot.com",
    [b]messagingSenderId[/b]: "*************6",
  [b]  appId:[/b] "1:******************************8"
  };
            // Initialize Firebase
            firebase.initializeApp(firebaseConfig);
            //get elements
            const preObject = document.getElementById('/');
            //create referencees
            const dbRefObject = firebase.database().ref();

            //sync object changes
            dbRefObject.once('value').then(function(snapshot) {
                console.log(snapshot.val());
                //display on pre tag 
                //preObject.innerHTML = snapshot.val();
            });
        }
    </script>
</body>
i get my data in the console but not on the web page.
here is the data type:

Andyroo

Re: Display data from Firebase database in a HTML page

Mon Sep 02, 2019 1:46 pm

As this is not a Pi specific topic I wonder if you would do better to review the notes from Google at https://firebase.google.com/docs/databa ... authuser=0 or the support group at https://groups.google.com/forum/m/#!forum/firebase-talk may be able to help more?

gauravsharma0190
Posts: 125
Joined: Tue Oct 28, 2014 6:36 am

Re: Display data from Firebase database in a HTML page

Tue Sep 03, 2019 4:10 am

Thank you for reply
i posted because i have seen one of this type of post here.

Return to “Other programming languages”