1

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/start Commented Oct 5, 2017 at 18:02
  • 1
    I 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. Commented Oct 5, 2017 at 18:15

1 Answer 1

3

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:

Add Firebase to your JavaScript Project

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.