Monday, 8 May 2017

Linking user uid to firebase database

I am currently making an app in react-native and would like to link userid generated from firebase authentication to user information in my firebase database.

{
  users:useruid:{
                  //Storing other user information
               }
}

I am retrieving the uid from auth and creating a new child for the users like this:

firebase.auth().onAuthStateChanged((user) => {

  console.log(user)

  if(user){

    user.getToken().then((userid) => {
      //Set the initial state
      firebase.database().ref('/users/').child(userid).set({
        'uid': userid,
        'businessName': business,
        'street address': street,
        'city': city,
        'state': state,
        'zipcode': zipcode,
        'productGroup': 0,
        'pom': 0,
        'som': 0,
        'inventory': 0,
        'reporting_and_analytics': 0,
        'accounting': 0
      })

      dispatch({type: types.REGISTER_USER_SUCCESS})

    }).catch(function(error){
      console.log(error.message)
      dispatch({type: types.REGISTER_BUSINESS_FAILURE, error});
    });
  }
  else{
    console.log("ERROR: Registration error")
  }
});

}

I am getting the error: Invalid path with regards to the uid generated. Any help. I have checked documentation on firebase and similar questions related to this but still getting the same error.

Error



via dorah

No comments:

Post a Comment