Here is the code snippet I am currently working with:
var process = async (items: DCXComposite[], session: Session) => {
// This function returns a response object with a statusCode property. If the status Code is 200, it indicates a successful operation.
return await session.performBatchOperation();
};
try {
var items: Composite[] = [];
for (const project of projects) {
items.push(project.getComposite());
if (items.length === 50) {
var result = process(items);
items = [];
}
}
} catch (err) {
Logger.error('Failed to delete projects in batch', { error: err });
}
I'm curious about how async/await works in this context. If one of the operations fails, does the entire process fail and trigger the catch block? In that case, would the next set of 50 projects not be processed? What happens if an error is thrown during the await phase?
The aim here is to efficiently delete multiple projects in batches through API calls. Each batch consists of sending a list of 50 projects to be deleted. Upon success, the process should return an object with a statusCode of 200.