0

My browser can normally open this link and return correct data, but if I run node in the shell, it will report an error. I even copied the example on github. Who can help me?

const axios = require('axios')

const address = '0x3F0627BB84C29f5577912c75cFBe905Ec18F6266'
const apiKey = 'HD4PCK2EVDUS3C5516C67WEXZP7JZNCR9M'
const url = `https://api.etherscan.io/api?module=contract&action=getabi&address=${address}&apikey=${apiKey}`

const getAbi = async () => {
  const res = await axios.get(url)
  const abi = JSON.parse(res.data.result)
  console.log(abi)
}
getAbi()

this error code: enter image description here

dependencies:

"@alch/alchemy-web3": "^1.4.1",
"axios": "^0.26.1",
"dotenv": "^16.0.0",
"express": "^4.18.2",
"mongodb": "^4.10.0",
"node-fetch": "^2.6.2",
"request": "^2.88.2"

NODE -V 16.15.0

Error Code:

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

<ref *1> Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read',
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [Function: httpAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json, text/plain, */*',
      'User-Agent': 'axios/0.26.1'
    },
    method: 'get',
    url: 'https://api.etherscan.io/api?module=contract&action=getabi&address=0x3F0627BB84C29f5577912c75cFBe905Ec18F626
6&apikey=HD4PCK2EVDUS3C5516C67WEXZP7JZNCR9M',
    data: undefined
  }

Eels
  • 1
  • 1
  • "dependencies": { "@alch/alchemy-web3": "^1.4.1", "axios": "^0.26.1", "dotenv": "^16.0.0", "express": "^4.18.2", "mongodb": "^4.10.0", "node-fetch": "^2.6.2", "request": "^2.88.2" } – Eels Oct 14 '22 at 16:20

0 Answers0