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.

32 lines
792 B

  1. import api from '../api';
  2. export const TRENDS_FETCH_REQUEST = 'TRENDS_FETCH_REQUEST';
  3. export const TRENDS_FETCH_SUCCESS = 'TRENDS_FETCH_SUCCESS';
  4. export const TRENDS_FETCH_FAIL = 'TRENDS_FETCH_FAIL';
  5. export const fetchTrends = () => (dispatch, getState) => {
  6. dispatch(fetchTrendsRequest());
  7. api(getState)
  8. .get('/api/v1/trends')
  9. .then(({ data }) => dispatch(fetchTrendsSuccess(data)))
  10. .catch(err => dispatch(fetchTrendsFail(err)));
  11. };
  12. export const fetchTrendsRequest = () => ({
  13. type: TRENDS_FETCH_REQUEST,
  14. skipLoading: true,
  15. });
  16. export const fetchTrendsSuccess = trends => ({
  17. type: TRENDS_FETCH_SUCCESS,
  18. trends,
  19. skipLoading: true,
  20. });
  21. export const fetchTrendsFail = error => ({
  22. type: TRENDS_FETCH_FAIL,
  23. error,
  24. skipLoading: true,
  25. skipAlert: true,
  26. });