import Axios from 'axios';

export const addFavoritesData = (data) => ({
  type: 'FAVORITES_DATA',
  data
});

export const getFavorites = () =>
  (dispatch: any) => {
    return Axios.get(`https://api.mixcloud.com/me/favorites?access_token=${localStorage.getItem('token')}&limit=20`)
      .then((res) => {
        dispatch(addFavoritesData(res.data));
      })
      .catch((e) => {
        throw new Error(e);
      });
  };
