Skip to content

Instantly share code, notes, and snippets.

@sandwichsudo
Last active July 27, 2017 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandwichsudo/6558cfe2f5e6fae76aedfca8ab730920 to your computer and use it in GitHub Desktop.
Save sandwichsudo/6558cfe2f5e6fae76aedfca8ab730920 to your computer and use it in GitHub Desktop.
New action structure
// src/containers/RepoSearchPage/actions/RepoSearchActions.js
import searchService from '../../../services/search/searchService';
import { actionTypes } from '../RepoSearchConstants';
export const fetchRepos = () => async (dispatch) => {
let error = '';
try {
const { items } = await searchService.repoSearch();
dispatch({
type: actionTypes.UPDATE_RESULTS,
items,
});
}
catch ({ message }) {
error = message;
}
dispatch({
type: actionTypes.REQUEST_COMPLETE,
error,
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment