Skip to content

Instantly share code, notes, and snippets.

@aigoncharov
Created January 5, 2019 23:19
Show Gist options
  • Save aigoncharov/e64dab647210b8365320aec98dfef040 to your computer and use it in GitHub Desktop.
Save aigoncharov/e64dab647210b8365320aec98dfef040 to your computer and use it in GitHub Desktop.
const catsGetAsync = async (dispatch) => {
dispatch(new CatsGetInit())
try {
const res = await fetch('https://cats.com/api/v1/cats')
const body = await res.json()
dispatch(new CatsGetSuccess(body))
} catch (error) {
dispatch(new CatsGetError(error))
dispatch(new GlobalErrorInit(error))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment