node.js - 在下面的代码中使用 Express GET 方法和 HTTPS GET 方法有什么区别?
问题描述
const express = require("express");
const app = express();
const https = require("https");
app.get("/", function (req, res){
var url = "https://***";
https.get(url, function(response){
console.log(response);
});
res.send("server running");
});
解决方案
app.get()
为本地 Express 服务器上的特定 INCOMING http 请求路径注册一个侦听器。
https.get()
向其他 https 服务器发出 OUTBOUND https 请求以从该其他服务器获取内容。
而且,显然,https.get()
使用的是 https,而不是 http。app.get()
可能正在监听任何一个 - 这取决于它所属的服务器是如何启动的(作为 http 服务器或 https 服务器),您在问题中的代码没有显示。
推荐阅读
- html - 从手机点击链接无效
- django - 如何根据现有的viewset和router配置viewset和router?
- python - 如何使用包含数据框名称的变量引用数据框?
- python - 使用 Numpy 的 Python 中的卷积层 - 使用 Strides
- python - 如何在 Python 中对布尔观测值进行聚类?
- javascript - 你将如何在javascript中提取字符串的一部分(模式)
- lua - Lua:如何使用 pcall 查看循环是否崩溃
- python - 将一维 pandas 数据帧转换为 N 维 numpy 数组
- python - 在python中交换两行
- android - getActivity() 在 Fragment 中变为 null