Skip to content

Instantly share code, notes, and snippets.

@trepidity
Created January 3, 2017 00:38
Show Gist options
  • Select an option

  • Save trepidity/30ec12ad9c2105cc4ddfd62408896588 to your computer and use it in GitHub Desktop.

Select an option

Save trepidity/30ec12ad9c2105cc4ddfd62408896588 to your computer and use it in GitHub Desktop.
import * as types from './actionTypes';
import songApi from '../api/songApi';
export function loadSongsSuccess(songs) {
return {type: 'LOAD_SONGS_SUCCESS', songs};
}
export function loadSongs() {
return function(dispatch) {
return songApi.getAllSongs().then(songs => {
dispatch(loadSongsSuccess(songs));
}).catch(error => {
throw(error);
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment