Skip to content

Instantly share code, notes, and snippets.

@susimsek
Created March 14, 2022 19:48
Show Gist options
  • Save susimsek/c5f4555d4a3e28e3843e520b79932cdd to your computer and use it in GitHub Desktop.
Save susimsek/c5f4555d4a3e28e3843e520b79932cdd to your computer and use it in GitHub Desktop.
Hateoas Redux
export const getAllCapabilitiesHandler = (getLink) => async dispatch => {
try {
const res = await getAllCapabilities(getLink);
dispatch({
type: GET_CAPABILITIES,
payload: res.data._embedded ? res.data._embedded.capabilities : [],
links: res.data._links,
page: res.data.page
});
} catch (error) {
dispatch({
type: GET_CAPABILITIES,
payload: [],
links: {},
page: {
totalPages: 0
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment