最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Postman post request stuck on sending - Stack Overflow

programmeradmin5浏览0评论

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

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

Share Improve this question edited Jan 26, 2021 at 8:20 Aziza Kasenova 1,5692 gold badges13 silver badges24 bronze badges asked Jan 25, 2021 at 18:54 Federico TarascioFederico Tarascio 331 gold badge1 silver badge5 bronze badges 2
  • @Adam nope, mongo connection is mented, even if it didn't it was ok no problems with that – Federico Tarascio Commented Jan 25, 2021 at 19:00
  • Try this:app.use(express.json()); app.use(express.urlencoded({extended: true})) – arevilla009 Commented Jan 25, 2021 at 19:24
Add a ment  | 

1 Answer 1

Reset to default 3

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)
});
发布评论

评论列表(0)

  1. 暂无评论