I am using request npm module and making 4 request inside of mainstream request. To say the conclusion first, only two of four request are succeed randomly.
Here is my code below.
router.get('/', function(req, res){
//TODO
request(url, function(error, response, body) {
if(err) throw error;
//TODO-
request(comnURL, function(errp,resp, body){
if(errp) throw errp;
comnBODY = body;
console.log(body);
console.log("\n\n");
});
request(intrURL, function(errp,resp, body){
if(errp) throw errp;
intrBODY = body;
console.log(body);
console.log("\n\n");
});
request(reptURL, function(errp,resp, body){
if(errp) throw errp;
reptBODY = body;
console.log(body);
console.log("\n\n");
});
request(addiURL, function(errp,resp, body){
if(errp) throw errp;
addiBODY = body;
console.log(body);
console.log("\n\n");
});
//TODO-
});
});
Every request of response is different randomly, chosen 2 of 4 sub-request. What could be the reason of this and how to avoid it.