Postman post request stuck on sending

Viewed 6146

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

1 Answers

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