https.get(url[, options][, callback])
曆史
版本 | 變化 |
---|---|
v10.9.0 |
|
v7.5.0 |
|
v0.3.6 | 添加於:v0.3.6 |
參數
url
<string> | <URL>options
<Object> | <string> | <URL> 接受與https.request()
options
,但method
始終設置為GET
。callback
<Function>
與
類似,但用於 HTTPS。http.get()
options
可以是對象、字符串或
對象。如果 URL
options
是一個字符串,它會被自動解析為
。如果是new URL()
對象,會自動轉換為普通的URL
options
對象。
const https = require('node:https');
https.get('https://encrypted.google.com/', (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
process.stdout.write(d);
});
}).on('error', (e) => {
console.error(e);
});
相關用法
- Node.js https.request(url[, options][, callback])用法及代碼示例
- Node.js https.createServer([options][, requestListener])用法及代碼示例
- Node.js https.request()用法及代碼示例
- Node.js ServerHttp2Stream http2stream.pushStream(headers[, options], callback)用法及代碼示例
- Node.js http.Agent.reuseSocket(socket, request)用法及代碼示例
- Node.js http2session.destroyed用法及代碼示例
- Node.js http.ServerResponse.setTimeout()用法及代碼示例
- Node.js http2.connect(authority[, options][, listener])用法及代碼示例
- Node.js http2session.type用法及代碼示例
- Node.js http.server.keepAliveTimeout用法及代碼示例
- Node.js http.validateHeaderValue(name, value)用法及代碼示例
- Node.js http2.bufferSize用法及代碼示例
- Node.js http.ClientRequest.maxHeadersCount用法及代碼示例
- Node.js http.IncomingMessage.httpVersion用法及代碼示例
- Node.js http.IncomingMessage.method用法及代碼示例
- Node.js http2session.ping()用法及代碼示例
- Node.js http2session.connecting用法及代碼示例
- Node.js http.IncomingMessage.aborted用法及代碼示例
- Node.js ServerHttp2Stream http2stream.respond([headers[, options]])用法及代碼示例
- Node.js http2stream.setTimeout()用法及代碼示例
- Node.js http.OutgoingMessage.removeHeader(name)用法及代碼示例
- Node.js http.IncomingMessage.complete用法及代碼示例
- Node.js http.validateHeaderName()用法及代碼示例
- Node.js http.IncomingMessage.rawTrailers用法及代碼示例
- Node.js http2session.setTimeout()用法及代碼示例
注:本文由純淨天空篩選整理自nodejs.org大神的英文原創作品 https.get(url[, options][, callback])。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。