2016-09-13 44 views
0

我正在嘗試構建一個Node.js控制檯應用程序,該應用程序將回調到Azure REST端點。具體來說,我想在端點上使用DELETE操作。我可以在Fiddler中成功設置請求。但是,我似乎無法從Node調用工作。我使用的是HTTPS模塊,在這裏我想以下幾點:Node.js - 通過HTTPS模塊運行DELETE

console.log('deleting search index.'); 
var options = { 
    host: 'https://test-service.search.windows.net', 
    path: '/indexes/test?api-version=2015-02-28', 
    port: 443, 
    method: 'DELETE', 
    headers: { 
    'api-key': '[Hidden]' 
    } 
}; 

var req = https.request(options, (res) => { 
    console.log('statusCode:', res.statusCode); 
    console.log('headers:', res.headers); 

    res.on('data', (d) => {}); 
}); 
req.end(); 

req.on('error', (e) => { 
    console.error(e); 
}); 

當我運行它,我得到一個錯誤,指出:

{ 
    [Error: getaddrinfo ENOTFOUND https://test-service.search.windows.net https://test-service.search.windows.net:443] 
    code: 'ENOTFOUND', 
    errno: 'ENOTFOUND', 
    syscall: 'getaddrinfo', 
    hostname: 'https://test-service.search.windows.net', 
    host: 'https://test-service.search.windows.net', 
    port: 443 
} 

我在做什麼錯?這對我來說是正確的。如果你已經在使用它已經知道協議的https模塊

回答