The following code is working with out superagent call as expected. Block the each callbacks. in the code sendRequest is not acting blocked; I see empty array at the end of program execution.
Any help in resolving would be appreciated. Thanks
process();
async function process() {
let data = await dataPreparation(collection);
console.log("data", data);
}
async function sendRequest(endPath, request) {
return await baseUrl.post(endPath)
.set('Accept', 'application/json')
.set('Content-Type', 'application/json')
.send(request)
}
async function dataPreparation(collection) {
let output = [];
await collection.each(async (items) => {
let tagName: string = items.name;
await items.content.each(async (item) => {
let rawRequest = item.request;
let endPath = item.endPath;
let response = await sendRequest(endPath, rawRequest);
output.push({ 'request': rawRequest, 'endPath': endPath, 'response': response.status });
})
});
return output;
}