当我尝试在节点中执行 https 发布请求时,出现 getaddrinfo ENOTFOUND 错误

Jon*_*ant 0 https oauth node.js instagram

完整的错误是这样的:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND https://api.instagram.com https://api.instagram.com:443
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
Run Code Online (Sandbox Code Playgroud)

我得到错误的代码是这样的:

var express = require('express');
var app = express();
var https = require('https');

app.get('/oauth/ig', function (req, res) {
  var options = {
    hostname: 'https://api.instagram.com',
    path: '/oauth/access_token?client_secret=myClientSecret&grant_type=authorization_code&redirect_uri=http://localhost:1992/oauth/ig&code='+req.query.code,
    method: 'POST',
  };
  var igRequest = https.request(options, (response) => {
    res.send("response");
  });
})
Run Code Online (Sandbox Code Playgroud)

我正在使用 nodejs 并且正在尝试进行 Instagram OAUTH。

msc*_*dex 5

hostname应该只是主机名,不包括协议:

hostname: 'api.instagram.com',
Run Code Online (Sandbox Code Playgroud)