0
我嘗試使用https.request
,但是當我想要訪問cookie響應時,這不會出現在資源頭部。 HTTP/HTTPS。無法使用HTTP/HTTPS的Nodejs獲取cookie
示例代碼:
let https = require('https');
https.request({
rejectUnauthorized: false,
hostname: 'example.com',
port: '443',
path: '/example.html',
method: 'POST',
headers: {
"Connection": "keep-alive",
"Accept-Encoding": "gzip, deflate, br",
"Upgrade-Insecure-Requests": "1",
"Content-Type": "application/x-www-form-urlencoded",
"Cache-Control": "no-cache",
"Pragma": "no-cache",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Accept-Language": "es-ES,es;q=0.8",
}
}, (res: any) => {
console.log('headers', res.headers); // this does not show 'set-cookie' property.
})
得餅乾支持嗎? 謝謝
P.S:我使用typescript
來編寫,ts-node
來運行這個腳本。
請向我們展示您正在使用的代碼,以便我們可以清楚地看到您在做什麼。 Cookies完全支持正確的代碼。 – jfriend00
對不起,感謝您的讚賞! –
'res.statusCode'的價值是什麼? – robertklep