How to do an http request to the request node.js?

Hi all!
Pliz tell me whether I'm doing the http request?
In the first query are event id and a second id for request event receive detailed information and you should print to the console a number of information from the first and second query. Here is an example of my code
Request.get({
 url: `https://example.com/?action=get_events&APIkey`,
 json: true,
 headers: {'User-Agent': 'request'}
 }, (err, res, body) => {
 if (err) {
 console.log('Error:', err);
 } else if (Res. statusCode !== 200) {
 console.log('Status:', res.statusCode);
 } else {

 if (body && body.length > 0) {

 for (let event of body) {

 let eventId = event.event_id

Request.get({
 url: `https://example.com/?action=get_events&${eventId}&APIkey`,
 json: true,
 headers: {'User-Agent': 'request'}
 }, (err, res, odds) => {
 if (err) {
 console.log('Error:', err);
 } else if (Res. statusCode !== 200) {
 console.log('Status:', res.statusCode);
 } else {

 if (odd && odd.length > 0) {

console.log(event.event_name);

}

}
});
}
}
}
 });


but with this solution there is a problem when only a few events in the list, they are okay if they become more part of them do not retrieve the info and show errors like this, and a small part is removed normally
Error: { Error: read ECONNRESET
 at _errnoException (util.js:1022:11)
 at TLSWrap.onread (net.js:628:25) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }


What could be the problem?
March 25th 20 at 13:45
0 answer

Find more questions by tags Node.jsJavaScript