First of all use Firebase Javascript CDN.
<script src=”https://www.gstatic.com/firebasejs/5.5.9/firebase.js”></script>
Then initialize the firebase app.
var config = { apiKey: "apiKey", authDomain: "projectId.firebaseapp.com", databaseURL: "https://databaseName.firebaseio.com", storageBucket: "bucket.appspot.com" }; firebase.initializeApp(config); Now Insert data into users document which is using as table here. firebase.database().ref('users/' + userID).set({ username: "x", email: "x@gmail.com", });
For fetching data from users document, use the following code code
var getUser = firebase.database().ref('users/'); getUser.on('value', function(snapshot) { console.log(snapshot.val()); });
Question and answer is powered by AnsPress.io