Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
abdulrahman
Contributor II
Contributor II

Firebase DB Connection

Hi,
I am trying to build an extension that sends data from its input fields to firebase db.
First i created a simple web app which seems to work fine, but when i integrated it to qliksense it doesnt send data to db instead it gives error "firebase not defined" in the console.
I dont understand what the problem is...
does qlik sense require some seprate connection to firebase db?
if yes then how?

This is my code:

<div qv-extension style="height: 100%; position: relative; overflow: auto;" class="ng-scope">


<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.8.2/firebase-app.js"></script>


<!--use this one for database-->
<script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-database.js"></script>

<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->

<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyA2Jv7TFnIoLu032LJVaYNkU9Bw3VFCWpw",
authDomain: "test-82f1f.firebaseapp.com",
databaseURL: "https://test-82f1f.firebaseio.com",
projectId: "test-82f1f",
storageBucket: "test-82f1f.appspot.com",
messagingSenderId: "858992366066",
appId: "1:858992366066:web:cd4d98dba75327d1cddb6b"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);


function sendData() {
firebase.database().ref("User").set({

name: document.getElementById('namefield').value,
age: document.getElementById('agefield').value

});
getData();
}


function getData() {
firebase.database().ref('/').once('value', function(snapshot){
snapshot.forEach(function(childSnapshot){
var childKey = childSnapshot.key;
var childData = childSnapshot.val();
document.getElementById("data").innerHTML = "<p><h3> Name : </h3><h5>" + childData['name'] + "</h5></p> <br> <p> <h3> Age : </h3><h5>" + childData['age'] + "</h5></p>";
})
})
}


</script>

<input type="text" placeholder = "Value1" id = "namefield">
<br>
<input type="text" placeholder = "Value2" id = "agefield">

<button onclick="sendData()">
Submit
</button>

<p id = "data"></p>

</div>

 

P.S: i didnt made any changes in js file of extension.

Labels (3)
0 Replies