Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
abdulrahman
Contributor II
Contributor II

Data not sent to Firebase DB

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