You can utilize redux-thud middleware which enables you to characterize async activities.
How about we take a case of bringing explicit record as an AJAX call utilizing get API:
trade work fetchAccount(id) {
return dispatch => {
dispatch(setLoadingAccountState())/Show a stacking spinner
get(‘/account/${id}’, (reaction) => {
dispatch(doneFetchingAccount())/Hide stacking spinner
on the off chance that (response.status === 200) {
dispatch(setAccount(response.json))/Use an ordinary capacity to set the got state
} else {
dispatch(someError)
}
})
}
}
work setAccount(data) {
return { type: ‘SET_Account’, information: information }
}​