I am very new in javascript and Firebase Database, and I cant quite comprehend how to send data to my database from it. I am sending data from an html document and I know how to record the information in to a variable, but now I want to send it to firebase and I dont know how to initialize the Firebase Database from Javascript. Thank you.
2
-
the firebase docs is a good place to search. firebase.google.com/docs/database/web/startOmarAguinaga– OmarAguinaga2017-10-05 18:02:23 +00:00Commented Oct 5, 2017 at 18:02
-
1I see that you are a very new user. New users are very important to us and we'd like to help you be more successful on this site. Please take a look at this Help Article about asking a good question that's likely to get a good answer.TecBrat– TecBrat2017-10-05 18:15:27 +00:00Commented Oct 5, 2017 at 18:15
Add a comment
|
1 Answer
You need to use JavaScript SDK of Firebase. Configure you app first.
<script src="https://www.gstatic.com/firebasejs/4.5.0/firebase.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
</script>
To read data:
firebase.database().ref('/list').once('value').then(function(data) {
// ...
});
read this documentation for more details: