Currently, I'm working on a firebase web application and encountering some challenges in identifying the root cause of an issue.
The main problem lies in my attempt to push data to my project using the unique identifier (uid) created during the authentication process. While the authentication itself is successful and returns the uid accurately, there seems to be an additional layer added before the actual values are passed.
function registerAccount() {
var firebase = app_firebase;
var firebaseRef = app_firebase.database(); //database reference
var user = firebase.auth().currentUser;
uid = user.uid;
var ref = firebaseRef.ref('User').child(uid); //referencing node
var userName = document.getElementById("txtUsernameInput").value;
if (user) {
// User is signed in.
var data = { //data being added
Username: userName,
}
window.location = 'myHome.aspx';
} else {
// No user is signed in.
console.log("Cannot get UID");
}
ref.push(data);
}
My expectation was for the data entry to display with the child node as the user's uid from the authentication (which is functioning correctly), followed by the passed values directly within the uid without any automatically generated intermediate children between them.
Here is the image illustrating the undesired field that is being generated:
[Click here to view][1]