I'm using a loop to query events, but the code after the loop is not executed. Why is this the case and how do I solve this problem?
router.post("/components/Pages/BrokerAPage/queryAll", (req, res) => {
var requestedResult;
for (i = 0; i < EventIDList.length; i++) {
queryEvent(EventIDList[i])
.then((result) => {
if (result) {
requestedResult += result;
}
})
.catch(err =>
res.send(JSON.stringify({ status: 'error', message: err.message})));
}
console.log("*************TEST************")
console.log("*************"+requestedResult+"*************")
res.json(JSON.stringify(requestedResult));
});
queryEventis fired multiple times?requestedResult.