Answer the question
In order to leave comments, you need to log in
How to properly handle Promise redux?
Hello. How to properly handle an asynchronous promise ?
export default connect(
null,
dispatch => ({
onLoginSystem: (account) => {
return dispatch(loginSystem(account));
}
})
)(AdminPanel);
export const loginSystem = (data) => {
return dispatch => {
return axios.post('/user', {
login: data.login,
password: data.password
})
}
}
this.props.onLoginSystem(account).then((response) => {
.... не работает
})
Answer the question
In order to leave comments, you need to log in
Judging by the code, you decided to involve redux in this business as well, so you need to supplement your example with a reducer and read data from it.
off.documentation
tutorial on ru (outdated, but the essence itself has not changed)
axios.post('/user', {
login: data.login,
password: data.password
}).then(({data})=>{
store.dispatch({
type:'ACTION',
data
})
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question