Dealing with asynchronous data flow
By default, Redux doesn't handle asynchronous data flow. There are several libraries out there that can help you with these tasks. However, for the purpose of this chapter, we will build our own implementation using middleware functions to give the dispatch
method the ability to dispatch and handle asynchronous data flow.
Getting ready
In this recipe, you will build an ExpressJS application with a very small API to test your application when making HTTP requests and dealing with asynchronous data flow and errors. First, create a new package.json
file with the following content:
{ "dependencies": { "express": "4.16.3", "node-fetch": "2.1.2", "redux": "4.0.0" } }
Then install the dependencies by opening a Terminal and running:
npm install
How to do it...
Build a simple RESTful API server that will have two endpoints or answer to paths /time
and /date
when a GET request is made. However, on /date
path, we will pretend that...