我使用NodeJS訓練myslef並嘗試了一個簡單的GET調用。 這裏是我的代碼:URL在瀏覽器中工作時,可能會導致「連接ETIMEDOUT」錯誤?
var http = require('http');
var options = {
host: 'www.boardgamegeek.com',
path: '/xmlapi/boardgame/1?stats=1',
method: 'GET'
}
var request = http.request(options, function (response) {
var str = ""
response.on('data', function (data) {
str += data;
});
response.on('end', function() {
console.log(str);
});
});
request.on('error', function (e) {
console.log('Problem with request: ' + e.message);
});
request.end();
調用的URL似乎在我的瀏覽https://www.boardgamegeek.com/xmlapi/boardgame/1?stats=1
工作不管怎樣,我得問題與要求:連接ETIMEDOUT當我運行的代碼,我沒有想法如何解決它。
什麼可能導致此錯誤?它是我的代碼還是網絡/代理問題?
你是否支持代理? – fiddler
是的,我有一個公司代理! – Alex