Answer the question
In order to leave comments, you need to log in
How to set sequential requests via axios in react+redux?
Result: it is necessary that the data be saved on the settings page.
I use react+redux. For forms I use redux-form. For requests I use axios.
The following sequence of actions is needed:
1. Send data by POST request to the server by pressing the "Save" button.
2. Immediately after successful sending, we receive the updated data with a GET request from the server and substitute them into the fields.
The problem is that it saves the data in the server database, but receives the data that is no longer relevant. Everything is decided by the fact that you need to refresh the page, and only then it receives the actual data from the database. But this is a bad decision.
CODE in comments
Answer the question
In order to leave comments, you need to log in
I solved this problem.. Thank you for your time.
The error was solved by replacing jquery.lib.js with a newer version..
you need to ask your api developer to return new data in response to a post request. then you get rid of the second GET request. or you can write your queries with promises or with async await. If you try to solve the problem using promises or async await and the problem remains, then write about the problem to your api developer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question