React/redux: making requests in the component or in action?

Study react + redox, write a mini-app with a backend written in node and have a question: where to make requests to the api?

Imagine the situation that there is some component to display the list of posts. Where better to do a query to get these posts? There are two options:
1. In the component is a query that gets a list of posts and transmitted to the stor through action, so these posts to keep in the store (caching, etc.)
2. Directly to action and then despacito another action and pass this list as payload?

I like the first option because I handle errors in the component and if an error has occurred -> I bring her in state, and thereby the component renders a message that something went wrong
March 19th 20 at 09:12
2 answers
March 19th 20 at 09:14
Solution
I like the first option because I handle errors in the component and if an error has occurred -> I bring her in state, and thereby the component renders a message that something went wrong

Wouldn't it be easier to treat her in action and immediately enter the store? So you have one source of truth and not have to duplicate the logic to operate the error state in each component.

View the response to a similar question
Yes, already read this question

About error handling in action I don't like the fact that in the case when the component depend on any data received from the server, then under this component should be in the store to create a separate field to store errors. This moment confuses me, because I want to in the store was only data, and errors were processed directly in the components - kaleb.Zieme commented on March 19th 20 at 09:17
@kaleb.Zieme, very weird. In store must be stored the global application state, not just data. The error came from the API there is the place. - dixie_Ri commented on March 19th 20 at 09:20
@dixie_Ri, do not argue, suggest that the strange variant
I just want to understand how to do it right, but now everything was clear, thank you! - kaleb.Zieme commented on March 19th 20 at 09:23
March 19th 20 at 09:16
Solution
In a shooter.
The first option you will begin to cause you problems at exactly the moment when you want the same query and the same data from another component.
In the components is "simple", but if you came to state to make redox-stor, and then do the next logical step.

Find more questions by tags ReduxReactAJAX