true;
for (i in urlsToMonitor) {
unirest.get(urlsToMonitor[i]).end(function (result) {
if (result.status != 200) {
allUrlsWorked = false;
}
});
}
//wait here until all urls have been tested
res.send(allUrlsWorked);
But I as far as I found out, there is no way to do this in JS because most JS engines have only one thread. Is it true?
Well, normally you don't really want to expose the state outside like that, you should use Promise.all or similar
I know. But sometimes there are also abnormal cases. For example checking some urls; and each url to check is in response body of the result of the previous url, like a chain.
Well you can always map and Promise.all, or just recurse
This sounds like a typical case where you want to recurse
Обсуждают сегодня