完整的錯誤是這樣的:當我嘗試做節點的HTTPS POST請求,我得到的getaddrinfo ENOTFOUND錯誤
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)
和我的代碼得到公正的錯誤是這樣的:
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("fuck it");
});
})
我正在使用nodejs,並試圖做Instagram OAUTH。
真棒,它的工作,但現在它只是永遠加載。任何想法爲什麼? –
我對instagram API不熟悉,也許您可能會問另一個問題,如果您有其他問題,請單獨提問。 – mscdex
「永久加載」的原因可能是因爲你沒有結束'igRequest'。使用'https.request()'要求你顯式調用'igRequest.end()'讓節點知道你的POST請求中什麼時候發送了正文內容。 – mscdex