The Keys array contains 1000 project key's.
for (var i = 0; i < Keys.length; i++){
httpRequest("https://hostname/api/issues/projectKeys="+Keys[i]+"?format=jSON",
function (err, res, body) {
var jsonObj = JSON.parse(body);
issue.push(jsonObj.total);
// console.log(issue.length);
}).auth(global.username, global.password);
}
The URL in the httpRequest returns a JSON. While I run this program, after 50-60 keys data is retrieved. My program is stopped due to an error.
SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse ()
Is it due to the asynchronous nature of NodeJS ? Please help How can I call the URL for 1000 times in a loop.
Here is the response
**{ Error: read ECONNRESET at _errnoException (util.js:1024:11) at TLSWrap.onread (net.js:615:25) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }**
I'm not sure what it is :( – Mudabbir Pasha Apr 26 '18 at 18:59