首页 > 解决方案 > 404 未在发布路线上找到

问题描述

我正在向这条路线发送一个帖子请求,但它不起作用并向我发送 404 Not Found Here 是该路线的代码

app.post('/case/new', (req, res) => {
    Case.create({
        name: req.query.name,
        paid: req.query.paid,
        assigned: req.query.assigned,
        description: req.query.description,
        date: req.query.date,
    }, (err, created) => {
        if(err){
            console.log(err)
        } else {
            res.send(created)
        }
    })
})

我在这里使用 jQuery 发送请求是 jQuery 代码

 
$.ajax({
     url: 'https://modern-clinic.herokuapp.com/new/case',
     type: 'POST',
     data: {
         name: this.state.name,
         description: this.state.desc,
         paid: this.state.paid,
         assigned: this.state.assigned,
         date: this.state.date
      }
})

标签: jquerynode.jsajaxexpresshttp-post

解决方案


$.ajax({
    url: 'https://modern-clinic.herokuapp.com/new/case',
    type: 'POST',
    dataType: 'json',
    data: {
        name: this.state.name,
        description: this.state.desc,
        paid: this.state.paid,
        assigned: this.state.assigned,
        date: this.state.date
    }
})

推荐阅读