Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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