Appendix. Installation

 

This appendix covers

  • Setting up a server
  • Installing axios
  • Configuring Redux Thunk
  • Updating the Redux DevTools

Setting up a server

Before you can start dispatching async actions, you need to do a few things:

  • Install and configure json-server, a popular tool for generating REST APIs quickly. This is a Redux book after all, so you don’t want to expend too much energy writing a fully featured back end. json-server allows you to specify a set of resources (such as tasks) and creates a standard set of endpoints to use.
  • Install axios, a popular AJAX library. There’s no shortage of popular AJAX libraries, including the new native browser API window.fetch, but axios is our choice due to a solid feature set and a straightforward API.
  • Install and configure Redux Thunk. You’ll have to add middleware to the Redux store, which is simpler than it might sound.

Installing and configuring json-server

First things first, install json-server globally by running the following command in a terminal window:

npm install --global json-server

Next create a db.json file in the root directory and add the contents shown in the following listing.

Installing axios

Redux Thunk

Configuring the Redux DevTools

Installing lodash

Installing Enzyme

Installation script