A
A
Alena Khrenovskaya2018-09-21 13:48:38
JavaScript
Alena Khrenovskaya, 2018-09-21 13:48:38

How to correctly send several consecutive post requests related to each other?

Guys, hello! Who will tell you how to correctly and painlessly implement the following:
I have a function (let it be f0) that calls the service method with a post-request. And she sends one object to the base.
And there are 3 more functions (f1, f2, f3) that process an array of objects and post each object to the database.
Well, the bottom line is that it should be sent as follows on a click on one button:
Until f0 sends an object to the database and returns its ID, f1 should not be called. Until f1 creates all array objects in the database and returns their IDs, f2 should not be called, and so with f3.
Returning id is important to me, because objects created in f1, f2, f3 must be attached to the main (first) object from f0, and some also to each other (objects from f3 are attached to f1 and f2).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question