带有节点js的Firebase实时数据库

时间:2017-07-02 06:52:25

标签: javascript node.js firebase firebase-realtime-database

我是firebase的新手,在web上开始使用firebase实时数据库。我写了以下代码来展示一个视频。但代码不起作用

<pre id="object"></pre>


<script>

    (function (){
        // Initialize Firebase
        var config = {
            apiKey: "<API KEY>",
            authDomain: "test-2c44d.firebaseapp.com",
            databaseURL: "https://test-2c44d.firebaseio.com",
            projectId: "test-2c44d",
            storageBucket: "test-2c44d.appspot.com",
            messagingSenderId: "329022996031"
        };
        firebase.initializeApp(config);

        const preObject = document.getElementById('object');

        const dbRefObject = firebase.database().ref().child('object');

        dbRefObject.on('value',snap => console.log(snap.val()));
    }());
    </script>

0 个答案:

没有答案