Unhandled promise rejection: Error: Actions must be plain objects. Use custom middleware for async actions. code example

Example: Actions must be plain objects. Use custom middleware for async actions

We cannot call Fetch from within an action creator in Redux.
That's because Redux is expecting objects as actions, but we're trying to 
return a Promise.

With redux-thunk (it's a middleware) we can overcome the problem and return 
functions from action creators. This way we can call APIs, delay the dispatch 
of an action.

//install redux-thunk
npm i redux-thunk