Skip to content

Instantly share code, notes, and snippets.

@ricardokdz
Last active May 3, 2017 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ricardokdz/a2c96b55b00e9b5a118f7f58adee5a9b to your computer and use it in GitHub Desktop.
Save ricardokdz/a2c96b55b00e9b5a118f7f58adee5a9b to your computer and use it in GitHub Desktop.
class Register extends Component {
constructor(props){
super(props)
this.state = {}
}
handleSubmit(){
const {name, email} = this.state
this.props.register(name, email)
}
...
- auth.js
export const register = (name, email) => {
return dispatch => {
dispatch(fetchStart())
apiRegister(name, email)
.then((response) => dispatch(register_success(response.data)))
.catch((error) => dispatch(register_failure(error.response.data)))
.then(dispatch(fetchStop()))
}
}
...
Reducer:
const INITIAL_STATE = {
logged_in: false,
access_token: null,
isError: false,
errorMessage: null,
isFetching: false,
user: {
id: null,
name: null,
email: null,
cpf: null,
cellphone: null,
is_active: null,
is_phone_validated: false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment