繁体   English   中英

nodejs npm 包 https.get() 和 https.request() 方法有什么区别

[英]what is the difference between https.get() vs https.request() methods of nodejs npm package https

https.get() 与 https.request()

请参阅文档

像 http.get() 但用于 HTTPS。

http.get说:

由于大多数请求是没有主体的 GET 请求,因此 Node.js 提供了这种方便的方法。 此方法与 http.request() 的唯一区别在于它将方法设置为 GET 并自动调用 req.end()。

“https.get”仅用于 GET 请求 - 这是一种特殊类型的 HTTP 请求,应仅用于检索数据。

在“https.request”中,您可以在“method”属性中指定您想要的任何 HTTP 方法 - 您可以使用“POST”(创建)、PATCH(更新)或 GET。

更多信息在这里:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM