Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to stop execution if one of the tasks failed?
Message
 
 
To
All
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Title:
How to stop execution if one of the tasks failed?
Miscellaneous
Thread ID:
01659020
Message ID:
01659020
Views:
38
Hi everybody,

I have the following code:
load($stateParams.draftId);

                getMetaData();
...
The load method has this code:
 spinnerService.startSpinner('loaditemtree');
                   
                    loadItemTreeRoot(draftId);
                    loadUnassigned(draftId);
The last 2 load functions as well as getMetaData call some service which returns promise. My problem is that I don't want to execute extra code if, for example, the very first method loadItemTreeRoot already returns a bad status.

How can I re-write the above to make sure my methods are executed in the synchronous fashion, to be precise, once one method failed (returned bad request), the rest of my methods are not executed?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform