Currently, I'm tackling a small project with AngularJS and finding myself tangled in multiple asynchronous calls that are starting to become chaotic. I know there must be a more efficient way to handle these calls, but I'm unsure of the best approach. Here is a snippet of my current code:
asyncCall1(someArgument,function(asyncCall1Response) {
// do some stuff
asyncCall2(asyncCall1Response.someAttribute,function(asyncCall2Response) {
// do some more stuff
asyncCall3(asyncCall2Response.someAttribute,function(asyncCall3Response) {
// finish doing stuff...or maybe call asyncCall4?!
});
});
});
I am seeking guidance on how to correctly utilize an asynchronous call's response as arguments when passing them into another asynchronous call. Any advice would be greatly appreciated!