How to Dispatch action which depends on Http method #1901
-
Which one is a good practice?
For example, what is the process of user login using state management? Here, I have to make an HTTP call & then I have to do something depending on the response I get from the HTTP response. Which one is good practice & why? Also, please share |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Usually you do an API call from the action handler within a state, then depends on what API returns, you are patch the state accordingly. Have a separate service that handle the calls. Check this SO answer for more details https://stackoverflow.com/questions/54557628/where-to-make-api-call-and-how-to-structure-actions |
Beta Was this translation helpful? Give feedback.
Usually you do an API call from the action handler within a state, then depends on what API returns, you are patch the state accordingly. Have a separate service that handle the calls. Check this SO answer for more details https://stackoverflow.com/questions/54557628/where-to-make-api-call-and-how-to-structure-actions