Jquery 在邮政路线上找不到404
我正在向该路线发送Post请求,但它不工作,并向我发送404未找到 这是路线的代码Jquery 在邮政路线上找不到404,jquery,node.js,ajax,express,http-post,Jquery,Node.js,Ajax,Express,Http Post,我正在向该路线发送Post请求,但它不工作,并向我发送404未找到 这是路线的代码 app.post('/case/new', (req, res) => { Case.create({ name: req.query.name, paid: req.query.paid, assigned: req.query.assigned, description: req.query.description,
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
}
})
一个是
/case/new
另一个是/new/case
..但它没有发送查询字符串在我修复它之后为什么要发送查询字符串?您发出POST请求是因为我不知道如何发送请求正文
本身。如果您收到404错误,则表示您尝试在不存在的url上发布。请检查您应该为$POST提供的确切url。”/case/new'或'/new/case'
$.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
}
})