Firebase - Adding additional user data to separate DB

前端 未结 2 1581
广开言路
广开言路 2020-12-09 05:53

I\'m new to Firebase and am using the email/password sign-in method. I have the method working fine however on my signup form I have additional fields I want to enter in the

相关标签:
2条回答
  • 2020-12-09 06:13

    For updating your database with additional parameters use the below given code and make changes accordingly.

    function writeUserData(userId, name, email, imageUrl) {
                    firebase.database().ref('users/' + userId).set({
                    username: name,
                    email: email,
                    profile_picture : imageUrl
                    });
                  }
    
    0 讨论(0)
  • 2020-12-09 06:35
    1. Initialization of firebase object was done for the old version, see this https://firebase.google.com/docs/web/setup , it uses firebase.initializeApp(config) instead of new firebase()

    2. to update your database with user's additional fields use this code

      firebase.database().ref('users/' + user.uid).set({
          firstName: firstName,
          lastName: lastName
      })
      
    0 讨论(0)
提交回复
热议问题