问题描述
const express = require('express');
const app = express();
const http = require('http').Server(app);
const port = process.env.PORT || 5000;
app.use(express.static(__dirname + '/public'));
http.on('request',(request,response) => {
console.log("the method request was " + request.method) //either prints POST or GET depending on what I'm sending it
if (request.method == "GET") {
console.log("GET")
} else if (request.method == "POST") {
console.log("POST")
}
request.on('error',(err) => {
// This prints the error message and stack trace to `stderr`.
console.error("the error was " + err);
});
// console.log("got a request to the server")
response.send("response string")
});
http.listen(port,() => console.log('listening on port ' + port));
所以基本上,问题是如果我发送 GET 请求,然后发送 POST 请求,它会打印所有正确的内容。但奇怪的是,如果我只是先发送 POST 请求,则没有打印输出。如果您需要查看我的客户端 Swift 代码,请告诉我,我会添加--谢谢!
可以在此处查看当前问题的视频:https://youtu.be/Rac9N9F4KDo
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)