0

I am using Axios in node.js and it is throwing exception while calling get http request in one of our project setup environment BUT same code works fine in my laptop. Do I need to explicitly set http_proxy in while calling axios , I am not sure, please help me in understanding the issue.

Below is my code:

async function executeGetOperation(url, endPoint) {
let result;

const headers = {
'x-functions-key': endPoint.FunctionKey,
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
};
    
 await axios.get(url, {
 headers: headers
 })
.then((response) => {
result = response.data;
})
.catch((err) => {
result = null;
 console.error(err);
 })
return result;
}

Exception:

{
    "message": "read ECONNRESET",
    "name": "Error",
    "stack": "Error: read ECONNRESET\n    at TLSWrap.onStreamRead (node:internal/stream_base_commons:220:20)",
    "config": {
        "transitional": {
            "silentJSONParsing": true,
            "forcedJSONParsing": true,
            "clarifyTimeoutError": false
        },
        "transformRequest": [
            null
        ],
        "transformResponse": [
            null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "env": {},
        "headers": {
            "Accept": "application/json, text/plain, */*",
            "x-functions-key": "****",
            "Cache-Control": "no-cache",
            "Pragma": "no-cache",
            "User-Agent": "axios/0.27.2",
            "host": "***"
        },
        "method": "get",
        "url": "*******"
    },
    "code": "ECONNRESET",
    "status": null
}
Ranjan V
  • 21
  • 4
  • Does this answer your question? [How do I debug error ECONNRESET in Node.js?](https://stackoverflow.com/questions/17245881/how-do-i-debug-error-econnreset-in-node-js) – DedaDev Jan 20 '23 at 06:36
  • No, Since it is working fine in my local laptop, it is not working only in our project setup. Earlier I was using request npm package and it was working fine in same project setup machine, now since request npm package is deprecated, we have replaced with axios and it is not working now ONLY in our project setup machine. – Ranjan V Jan 20 '23 at 07:08

0 Answers0