Hierarchy of requests with Await [closed]

0

Next ... I need to make a hierarchy of requests that depend on each other.

I made the whole structure, but when I run the code they are solved asynchronously, without waiting for a request to be solved to follow the code just below.

Here's how the structure is:

This is the requisition where it is done

Thisisthemethodintheservice:

AfterSyncDevicesstartstheRequisitionHierarchy:

And after fetchHeaders there are several others like SyncDevices, one depending on the other and being solved one after the other. But I need to resolve the TryRecconectAccount function because by having its response I can remove the loading on the screen.

If anyone has any idea what I can do ... Thanks

    
asked by anonymous 06.11.2018 / 22:12

1 answer

3

This is not a verifiable example, so I do not know if this will suffice, but I can see some problems in your code.

The tryReconnectAccount function, although asynchronous, does not expect the return of this.syncDevicesFeatures , it only calls the function and immediately returns undefined (any function without explicit return returns undefined) before syncDevicesFeatures ends execute.

If syncDevicesFeatures returns a promise (or for async), you could use

 async tryReconnectAccount(data, headers, props, account) {
     return await this.syncDevicesFeatures(data, headers, props, account);
 }

I'm actually not seeing a reason for tryReconnectAccount to exist, since it just invokes syncDevicesFeatures with the same parameters.

    
06.11.2018 / 22:33