0

I am using firebase to insert the user into database , name , email , ip ect, to get the IP i am using react native public ip that contains publicIP function that Returns a Promise for the IP address, my issue is that firebase fires an error saying that

reference set failed : first argument contains undefined ..

 const ip =  getIP();
        firebase.database().ref(`mydatabase/${userId}`)
        .set({ name ,email,ip,radio,backgr})
        .then( async() => { dispatch({ type: SIGNUP_SUCCESS }); 
    })
        .catch(error => handleError(dispatch, error.message));

     }
const getIP =  () => {
        let ipz = '111.11.111.11';
        publicIP()
        .then(ip => {
             myipx(ip);

        })
        .catch(error => {
            ipz = 'noIp';
    });

  };
  const myipx = ip => {
     return ip;
  }
salmanaacvf
  • 235
  • 7
  • 23
  • the function you pass to `then` does not return anything. use `.then(myipx).catch(() => "noIp")`. `getIP()` does not return anything either. Your functions have to `return` something to return something. – Thomas Jul 09 '19 at 10:16
  • you are setting values via set({ name ,email,ip,radio,backgr}) but its variable name,email etc are never defined – Arvind Rajput Jul 09 '19 at 10:43

0 Answers0