Sep 2, 2018 · 1 min read
Im just gettion an error when start function on class
const LoginAction = (data) => (dispatch) => {
dispatch({
type: ‘LOGIN_IN_ACTION’
})
new Promise((resolve, reject) => {
axios.post(‘/api/login’, {
user_email: data.user_email,
user_password: data.user_password
}).then(res => {
setTimeout(() => {
dispatch({
type: ‘LOGIN_ACTION’,
payload: res.data
});
resolve(res.data);
}, 2000);
}).catch(err => {
console.error(err)
reject(err);
});
});
}
export { LoginAction }
then
submitHandler() {
dispatch(this.props.LoginAction(this.state)).then(res => {
console.log(res)
});
}
and then
Uncaught ReferenceError: dispatch is not defined