I'm currently working on a registration app and it's my first time using firebase.
My email address is successfully stored in the authentication section of firebase. However, when I try to connect my app to the database to store additional information, I encounter an error message upon clicking the signup button:
Error: Reference.child failed: First argument was an invalid path = "undefined". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"
at validatePathString (firebase.js:1)
at t.child (firebase.js:1)
at userServices.js:30
at angular.js:14634
at m.$eval (angular.js:15878)
at m.$digest (angular.js:15689)
at angular.js:15917
at e (angular.js:5490)
at angular.js:5762
Below is the snippet of my code that is causing the issue:
angular.module("registrationApp")
.factory("signupService", ["$rootScope", "$firebaseAuth", signupService]);
function signupService($rootScope, $firebaseAuth) {
var ref = firebase.database().ref();
var auth = $firebaseAuth();
return {
signup: function (user) {
auth.$createUserWithEmailAndPassword(
user.email,
user.password
).then(function (regUser) {
var userInfo = ref.child("Users")
.child(regUser.uid).set({
date: firebase.database.ServerValue.TIMESTAMP,
regUser: regUser.uid,
firstname: user.firstName,
email: user.email
})//userInfo
$rootScope.message = "Hi " + user.firstName + " " + "Thanks for Registering";
}).catch(function (error) {
$rootScope.message = error.message;
})
}
}
}`