Skip to content

Remote API

Melissa Stock edited this page Jul 4, 2019 · 1 revision

Async Actions

  1. An action informing the reducers that the request began.
  • The reducers may handle this action by toggling an isFetching flag in the state. This way the UI knows it's time to show a spinner.
  1. An action informing the reducers that the request finished successfully.
  • The reducers may handle this action by merging the new data into the state they manage and resetting isFetching. The UI would hide the spinner, and display the fetched data.
  1. An action informing the reducers that the request failed.
  • The reducers may handle this action by resetting isFetching. Additionally, some reducers may want to store the error message so the UI can display it.
  1. Pay close attention to the shape of the state (how you're storing the information) before starting your implementations because async actions require a lot of state changes

Redux thunk

  • Redux Thunk makes it easy to dispatch actions that follow the lifecycle of a request to an external API.

Clone this wiki locally