In javascript async await function we can write something like this:
const campaigns = await this.$api.campaigns.getCampaigns({all});
const campaigns2 = await this.$api.campaigns.getCampaigns({all});
const campaigns3 = await this.$api.campaigns.getCampaigns({all});
It causes that campaigns2 and campaigns3 will wait for the end of first request. In javascript there should be also possible something like this:
const campaigns = this.$api.campaigns.getCampaigns({all});
const campaigns2 = this.$api.campaigns.getCampaigns({all});
const campaigns3 = this.$api.campaigns.getCampaigns({all});
await campaigns;
await campaigns2;
await campaigns3;
this.campaigns = campaigns3.data.data;
This code should make 3 paralel requests for campaigns1,2,3 variables where campaigns2 and campaigns3 dont have to wait for the end of promisse of first request is done. It is possible but in Vue 2 it does not work. It throws me an error:
TypeError: Cannot read properties of undefined (reading 'data')
Can somebody tell me please why? Thank you.