Reputation: 13
I have database that i am trying to populate with variables from a Javascript website, to test it I wrote the following code.
Initializing code (all the variables are populated accordingly, taken from the Database API):
function Firebase(){
var config = {
apiKey: "(Key)",
authDomain: "(Domain),
databaseURL: "(URL)",
projectId: "(ProjectID)",
storageBucket: "(Bucket)",
messagingSenderId: "(ID)"
};
firebase.initializeApp(config);
To set data I have the following code
var rootRef = firebase.database().ref();
rootRef.set({
name: Kemper,
}).then(success =>
{ console.log('success',success);
},
error => {
console.log('error',error);
}
);
Firebase() Will be initialized when the submit button is clicked, with the following code:
<input type = "submit" onclick="Firebase()" action = "welcome.php" id="submit"></button>
The code does not show the success or error console.log, and I cannot find the issue with it. Thank you for your time.
Upvotes: 0
Views: 373
Reputation: 4858
The problem is that you are trying to save a string as number.
The .set()
call should look like this:
rootRef.set({
name: "Kemper", // quotation marks added
})
Upvotes: 1