Answer the question
In order to leave comments, you need to log in
How to chain requests in redux?
Hello, I'm learning redux in conjunction with reactjs. Tell me how to correctly implement a chain of asynchronous calls. There is a list of users. When clicking on a user:
1. Authenticate. (asynchronous request
2. Take the user's token
3. With the user's token, make an asynchronous request to receive the user's messages.
How can this be done leaving the actions for authentication and the action for receiving a post independent?
Answer the question
In order to leave comments, you need to log in
https://github.com/reactjs/redux/issues/911#issuec...
https://github.com/acdlite/redux-promise
If I understand you correctly, in order for them to remain independent, you need to save the token. For example, in the props of the component if it is "stupid", or it is possible in the state if the component is "smart" (in other words, an unconnected component, or connected (using the connect function))
1. Authenticate
2. Save the token to the component
3. Do request with user token.
Point 3 can be improved, for example, do not highlight the button to make a request without a token.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question