You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
682 B

  1. import api from '../api';
  2. export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST';
  3. export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS';
  4. export const LIST_FETCH_FAIL = 'LIST_FETCH_FAIL';
  5. export const fetchList = id => (dispatch, getState) => {
  6. dispatch(fetchListRequest(id));
  7. api(getState).get(`/api/v1/lists/${id}`)
  8. .then(({ data }) => dispatch(fetchListSuccess(data)))
  9. .catch(err => dispatch(fetchListFail(err)));
  10. };
  11. export const fetchListRequest = id => ({
  12. type: LIST_FETCH_REQUEST,
  13. id,
  14. });
  15. export const fetchListSuccess = list => ({
  16. type: LIST_FETCH_SUCCESS,
  17. list,
  18. });
  19. export const fetchListFail = error => ({
  20. type: LIST_FETCH_FAIL,
  21. error,
  22. });