I am trying to loop this entire 'request.post' but it comes up as an error: "TypeError: Cannot read property 'id' of undefined". Is there a way that I can loop the entire 'request.post'?
for (var i = 0; i < 2; i++){
request.post(
'url',
{ json: {"category":category,"sub_category":subcategory,"contest_status":2} },
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body['contest_report'][i].id);
}
}
);
}