August 2017
Beginner
374 pages
10h 41m
English
Now we are handling the _SUCCESS and _REQUEST action types. However, there is still one possible result: _FAILURE. When an error happens, we want to display it in the interface so that the user knows something went wrong.
We start by producing an error so that we can see what happens while we implement error handling. Edit server/api/posts.js and replace the first route (GET /api/posts) with the following code:
app.get('/api/posts', (req, res) => { throw new APIError('something went wrong!') res.send(db.getPosts()) })
Read now
Unlock full access