Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 16, 2020 10:02
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 velotiotech/a05767f7eb8b438e6c021f6db15fa428 to your computer and use it in GitHub Desktop.
Save velotiotech/a05767f7eb8b438e6c021f6db15fa428 to your computer and use it in GitHub Desktop.
const getPostById = async (dispatch, id) => {
dispatch({ type: GET_POSTS_BY_ID_REQUEST });
try {
const response = await getPostsById(id);
const res = await response.json();
dispatch({ type: GET_POSTS_BY_ID_SUCCESS, payload: res });
} catch (e) {
dispatch({ type: GET_POSTS_BY_ID_FAIL, payload: e });
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment