'ECONNRESET error in Nodejs while calling API request

I'm using NodeJS in my application, I'm trying to call API service to get the token from the server. While I'm making any request from the NodeJS file I'm getting "ECONNRESET" error. I've tried with some API , which reflects the same error. Below is my code

import request = require('request');

request('https://postman-echo.com/get?foo1=bar1&foo2=bar2', (err,result,body){
 console.log(body);
});

The above is my code which I've tried with sample API. When I'm trying to run this code I'm getting

Error: read ECONNRESET 
       at TLSwrap.onstreamread( interal/stream_base_common.js:207:27 {
       error: -4077,
       code: ECONNRESET,
       syscall: read
}


Solution 1:[1]

Check if you have a proxy. This error occurs when not able connecting to the server.

Check your browser's proxy connection and Check your machine's proxy connection

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1