Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

javascript - 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. 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.

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"

Postman app

I'm using postman 8.0.2 desktop app for mac, i've tried to remove and install again.

EDIT I've tried creating another project and it works again i'll investigate on what i did wrong and maybe add a comment.

question from:https://stackoverflow.com/questions/65890736/postman-post-request-stuck-on-sending

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...