R
R
Romi2022-01-04 19:04:15
JavaScript
Romi, 2022-01-04 19:04:15

How is it customary to collect a single object from interconnected data that came from different sources (via axios)?

The situation is this:

1. A table is being built in Vue.

2. The data for which is obtained via axios.get() from several uri

3. Moreover, the data is interconnected, i.e. roughly speaking: an array of objects comes from one uri, and an array with keys for selecting these objects comes from the other.

4. Accordingly, if the data did not come in one place, undefined may happen in another

. Since axios is asynchronous, I usually put dependent functions in the then() block in such cases - and it worked.

But when there are a lot of these dependencies, the head starts to spin :)

Tell me, is there any suitable pattern for such cases?

Those. how, for example, to wait for all 4 (say) data sources with different uri to be loaded first through axios, and only then, in case of successful loading, to perform some actions with them?

How to do it?

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2022-01-04
@romicohen

Combine a bunch of requests that must come through
https://developer.mozilla.org/en-US/docs/Web/JavaS...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question