I have a firebase database having a child - "hello" having value - "one". Now, using the javascript, I need to set the value of "hello" as "two". Thanks in advance. Please help.
This is a really basic question. The answer can be easily found in the firebase docs. I'd strongly recommend you to always keep an eye on the docs when learning how to use firebase, because it is a great source and it covers a lot of use cases.
First, initialize your app
var config = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>'
};
firebase.initializeApp(config);
Then, in your javascript, make sure you have a valid reference to your database and then run either one of these lines
firebase.database().ref("hello").set('two');
or
firebase.database().ref().update({hello: 'two'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With