小编Eri*_*607的帖子

发送 https 请求 Node.js 和 API 时出现错误:getaddrinfo ENOTFOUND

我正在开发一个仪表板,我需要连接到 API 并捕获身份验证令牌,然后使用 HTTPS 协议发送信息。我使用 Nodejs,当我运行代码时,pm2 monit 上出现下一个错误:

Error: getaddrinfo ENOTFOUND my.url.net/path
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'my.url.net/path'
}
Run Code Online (Sandbox Code Playgroud)

这也是我发出请求的代码(Node.js):

const path = require('path');
require('dotenv').config({path: path.join('path','.env')});
const https     = require('https');
const database = require('./sql');
const fs         = require ('fs');

const user = process.env.USER;
const pwd  = PWD;
const host = 'https://my.url.net/extencio';
const host_1 = 'my.url.net/extention';

async function getLoginToken(pForce){

 if (login_token.Health && !pForce) { return login_token }

  //Creates the POST request
  const options …
Run Code Online (Sandbox Code Playgroud)

javascript ssl https node.js npm

3
推荐指数
1
解决办法
4万
查看次数

标签 统计

https ×1

javascript ×1

node.js ×1

npm ×1

ssl ×1