【问题标题】:Error "connect ECONNREFUSED" when sending a request using Axios使用 Axios 发送请求时出现“连接 ECONNREFUSED”错误
【发布时间】:2020-12-07 04:21:45
【问题描述】:

我在发送请求以在 Nodejs 获取请求中使用 Axios 时收到此错误。我正在调用第 3 方 API。

{
  "message": "connect ECONNREFUSED 198.54.117.197:443",
  "name": "Error",
  "stack": "Error: connect ECONNREFUSED 198.54.117.197:443\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)",
  "config": {
    "url": "https://swapi.co/api/starships/9",
    "method": "get",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "User-Agent": "axios/0.21.0"
    },
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
    "maxBodyLength": -1
  },
  "code": "ECONNREFUSED"
}

我的代码 https://github.com/bilalyaqoob/caching-with-node-js-redis

谁能帮帮我?

【问题讨论】:

  • 远程服务器似乎不接受您的请求。请检查您是否有正确的身份验证设置以及 API 是否正常工作。
  • 我正在使用这个swapi.dev

标签: node.js axios


【解决方案1】:

您使用的是过时的端点。在网站上,它声明您需要使用 https://swapi.dev/api/starships/9/ 而不是 ttps://swapi.co/api/starships/9 。 他们从 .co 域名转移到了 .dev 域名。

【讨论】:

    猜你喜欢
    • 2020-06-18
    • 2021-12-05
    • 1970-01-01
    • 2021-05-01
    • 2021-05-14
    • 2019-06-12
    • 2020-10-26
    • 2020-03-06
    • 2020-06-07
    相关资源
    最近更新 更多