[英]Postman post request stuck on sending
(Express) Hello I'm trying to make a very simple post request to localhost via postman but it gets stuck on sending. (Express) 您好,我正在尝试通过 postman 向 localhost 发出一个非常简单的发布请求,但它在发送时卡住了。 To be clear, the first time I've tried it, it worked, but after adding a mongoose implementation it didn't work anymore even after commenting the changes.
需要明确的是,我第一次尝试它时,它起作用了,但是在添加了 mongoose 实现之后,即使在评论更改后它也不再起作用了。
const router = require('express').Router();
router.post('/', (req, res) => {
console.log("Got here");
res.send("ciao");
});
app.listen(port, () => {
console.log("Server running on port: " + port);
});
If it was working correctly I'd see "Got here"如果它工作正常,我会看到“到了这里”
I'm using postman 8.0.2 desktop app for mac, i've tried to remove and install again.我正在使用适用于 mac 的 postman 8.0.2 桌面应用程序,我尝试删除并再次安装。
EDIT I've tried creating another project and it works again i'll investigate on what i did wrong and maybe add a comment.编辑我已经尝试创建另一个项目并且它再次工作我将调查我做错了什么并可能添加评论。
add router as middleware to the express, below is your updated code将路由器作为中间件添加到快递中,下面是您更新的代码
const router = require('express').Router();
router.post('/', (req, res) => {
console.log("Got here");
res.send("ciao");
});
app.use('/', router);
app.listen(port, () => {
console.log("Server running on port: " + port)
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.