[Solved] Accounts.createUser() Creates account but does not execute callback

I am using Accounts.createUser to create accounts in DB.it works and creates accounts but after it i am trying to navigate home screen but its not working for some reason.

register = () => {
    console.log("i got called")
    const options = {
      email:this.state.email,
      username:this.state.username,
      password:this.state.password,
      reservations:[]


    }


//this.setState({loading:true});
      Accounts.createUser(options),function(err){
if(err){
console.log(error)//no errors in console.

}else{ //succesfully creates user 
console.log("lets navigate!") // not working this code is not executed.

this.props.navigation.navigate('Home');
}


    }

  };

You’re not passing the function as a callback.

createUser(options),function(err) should be createUser(options, function(err)

Also, as you’re using this inside the callback, you need to use arrow callback (err) => { instead so this will refer to the react component.

2 Likes

i should go to sleep

1 Like

yes :stuck_out_tongue: