асинхронном actions вызываю диспатч и ничичего не происходит, дебагер доходил до места диспатча, с чем может быть проблема?
const Actions = {
fetchDataStart: () => ({
type: "DASHBOARD:SET_LOADING_DATA_REQUEST"
}),
setDataSuccess: () => ({
type: "DASHBOARD:SET_LOADING_DATA_SUCCESS"
}),
setDataFailure: () => ({
type: "DASHBOARD:SET_LOADING_DATA_FAILURE"
}),
setFingerprintNames: (arr) => ({
type: "DASHBOARD:SET_FINGERPRINT_NAMES",
payload: arr
}),
setStatus: (bool) => ({
type: "DASHBOARD:SET_STATUS",
payload: bool
}),
setCurrentFingerprintName: (name) => ({
type: "DASHBOARD:SET_CURRENT_FINGERPRINT_NAME",
payload: name
}),
setIsProfileReady: (bool) => ({
type: "DASHBOARD:SET_IS_PROFILE_READY",
payload: bool
}),
setIsStarted: (bool) => ({
type: "DASHBOARD:SET_IS_PROFILE_START",
payload: bool
}),
becomeAllUserProfiles: (login) => async (dispatch) => {
const token = localStorage.getItem("token");
axios
.post(
process.env.REACT_APP_PUBLIC_API + ‘/api/data,
{
login
},
{
headers: {
authorization: token
}
}
)
.then(({ data }) => {
let profileNames = [];
data.forEach((item) => {
if (item.profileName !== undefined) {
profileNames = [...profileNames, item.profileName];
}
});
dispatch(Actions.setFingerprintNames(profileNames));
dispatch(Actions.setDataSuccess());
})
.catch((err) => {
dispatch(Actions.setDataFailure());
});
},
}
а зачем вобще обектом писал?
Обсуждают сегодня