我与阵营终极版的工作,我试图调用另一个函数内部功能上我的行动文件。问题是,它只有当我走功能的调度部分的工作。
我wan't调用从askForUser()updateToken(),但如果我把派遣部分来自updateToken它只会工作()。此外,当我打电话从askForUser askForUser()(),它不会工作的。
const updateToken = (token) => dispatch => {
console.log(token)
dispatch({
type: UPDATE_TOKEN,
payload: token
})
}
const askForUser = (token) => dispatch => {
dispatch({ type: ASKING_FOR_DATA })
axios.get(API.GET_USER, {
params: {
token
}
}).then((response) => {
if (response.data.status === 1) {
dispatch({ type: ASK_FOR_USER, payload: response.data.user })
} else if (response.data.status === 2) {
updateToken(response.data.token)
//console.log(hola2())
} else {
NotificationManager.error('Error consiguiendo usuario')
dispatch({ type: ERROR_HANDLER })
}
}).catch((err) => {
console.log(err)
dispatch({ type: ERROR_HANDLER })
})
}
你必须dispatch
它:
else if (response.data.status === 2) {
dispatch(updateToken(response.data.token)); // dispatch the function here
}