Open gozes opened 7 years ago
I did it with redux-thunk
and it works well.
const actionSomething = () => (dispatch, getState) => {
dispatch(/* pending like action type */);
try {
const data = async () => {
return await fetch('URL').then(response => response.data)
.catch(err => err);
}
} catch (err) {
return dispatch(/* failed like action */);
}
return dispatch(/* success like action */);
}
do I need use redux thunk with this middle where if my action creator calls store.dispatch/dispatch before calling an async function/arrow function?