A
A
Andrey Sergeev2020-11-07 12:31:06
JavaScript
Andrey Sergeev, 2020-11-07 12:31:06

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

4 answer(s)
A
Andrey Burov, 2016-07-01
@BuriK666

you have an error elsewhere, everything is OK here

D
Dima, 2016-07-01
Gorichey

I solved this problem.. Thank you for your time.
The error was solved by replacing jquery.lib.js with a newer version..

R
Roman Alexandrovich, 2020-11-07
@RomReed

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.

S
Sergey Suntsev, 2020-11-07
@GreyCrew

Better use Redux thunk for queries

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question