trc-client-core
Version:
The core of the TRC Client
23 lines (22 loc) • 756 B
JavaScript
import xhr from 'trc-client-core/src/utils/xhr';
import {createAction} from 'redux-actions'
import {
VEHICLES_ENDPOINT
} from 'trc-client-core/src/constants/Endpoints';
import {
VEHICLES_FETCH,
VEHICLES_RECEIVE,
VEHICLES_ERROR
} from 'trc-client-core/src/constants/ActionTypes';
const vehiclesFetch = createAction(VEHICLES_FETCH);
const vehiclesReceive = createAction(VEHICLES_RECEIVE);
const vehiclesError = createAction(VEHICLES_ERROR);
export function vehiclesRequest(query) {
return (dispatch, getState) => {
dispatch(vehiclesFetch(query));
xhr.get(VEHICLES_ENDPOINT).then(
(data) => dispatch(vehiclesReceive(data)),
(error) => dispatch(vehiclesError(error))
);
};
}