sforkowany z mirror/soapbox
29 wiersze
685 B
JavaScript
29 wiersze
685 B
JavaScript
import api from '../api';
|
|
|
|
export const FILTERS_FETCH_REQUEST = 'FILTERS_FETCH_REQUEST';
|
|
export const FILTERS_FETCH_SUCCESS = 'FILTERS_FETCH_SUCCESS';
|
|
export const FILTERS_FETCH_FAIL = 'FILTERS_FETCH_FAIL';
|
|
|
|
export const fetchFilters = () => (dispatch, getState) => {
|
|
if (!getState().get('me')) return;
|
|
|
|
dispatch({
|
|
type: FILTERS_FETCH_REQUEST,
|
|
skipLoading: true,
|
|
});
|
|
|
|
api(getState)
|
|
.get('/api/v1/filters')
|
|
.then(({ data }) => dispatch({
|
|
type: FILTERS_FETCH_SUCCESS,
|
|
filters: data,
|
|
skipLoading: true,
|
|
}))
|
|
.catch(err => dispatch({
|
|
type: FILTERS_FETCH_FAIL,
|
|
err,
|
|
skipLoading: true,
|
|
skipAlert: true,
|
|
}));
|
|
};
|