function createUser(user) {
    return (dispatch) => {
        return new Promise((resolve, reject) => {
            const userRef = database.ref().child('users');

            userRef.child(user.uid).update({...user})
                .then(() => {
                    dispatch({type: t.LOGGED_IN, user});
                    resolve(user)
                })
                .catch((error) => reject({message: error}));
        });
    }
}
//Create the user object in realtime database
Create the user object in realtime database
Create the user object in realtime database
function createUser(user) {
    return (dispatch) => {
        return new Promise((resolve, reject) => {
            const userRef = database.ref().child('users');
            userRef.child(user.uid).update({...user})
                .then(() => {
                    dispatch({type: t.LOGGED_IN, user});
                    resolve(user)
                })
                .catch((error) => reject({message: error}));
        });
    }
}
function createUser ( user ) { return ( dispatch ) => { return new Promise ( ( resolve , reject ) => { const userRef = database . ref ( ) . child ( 'users' ) ; userRef . child ( user . uid ) . update ( { ... user } ) . then ( ( ) => { dispatch ( { type : t . LOGGED_IN , user } ) ; resolve ( user ) } ) . catch ( ( error ) => reject ( { message : error } ) ) ; } ) ; } }
Create the user object in realtime database
Create the user object in realtime database