score:1

Accepted answer
npm install redux@^4.0.0

score:0

export function fetchData() { 
    return function(dispatch) {
        return fetch( ... ).then( ... ).catch( ... )
    }
}


export const fetchData = (params) => dispatch => {
    dispatch(beginAjaxCall());
    return fetch(...).then(response => {
        dispatch(someFunction(response));
    }).catch(error => {
      throw(error);
    });
}


export const loadIncidents = (params) => dispatch => {
    dispatch(beginAjaxCall());
    return IncidentsApi.getIncidents(params).then(incidents => {
       dispatch(loadIncidentsSuccess(incidents));
    }).catch(error => {
        throw(error);
    });
}

Related Query

More Query from same tag