Design Pattern to loop over a list of data and make async calls

Is there a pattern where you can loop over a list of data (dynamically derived in JS Policy) and then loop over this list and Service callout - with the data from the loop being part of the URL path. Essentially

Step 1: const filteredAndMappedData = dynamicArrayOfString.filter(...).map(...);
Step2: const listOfResponses = filteredAndMappedData.forEach(data => return ServiceCallout for the `data`);
0 2 273
2 REPLIES 2

You can do multiple asynchronous service callouts in Javascript with httpClient: https://docs.apigee.com/api-platform/reference/javascript-object-model.html#makingjavascriptcallouts... but please keep in mind that waitForComplete is not good for performance, so get() with a completion function is probably what you want here: https://docs.apigee.com/api-platform/antipatterns/wait-for-complete

Perfect. Does `send` support a callback function too? It wasnt very obvious in the documentation of `httpClient`.