【发布时间】:2018-04-13 20:49:08
【问题描述】:
我正在尝试使用以下代码将一些数据从 Vue.js 发布到基于 Symfony 的后端。
updateQuestion : function() {
axios.post('/staff/question/api/' + this.id,{
id : 'test',
name : 'sree'
})
.then( response => {
console.log(response);
})
.catch(error => {
console.log(error);
})
},
但是,我附加到 POST 请求的参数没有到达我的控制器。所以,我尝试了 POST 请求的替代格式,但参数仍然没有到达控制器。请告诉我有什么问题。
替代格式:
updateQuestion : function() {
axios({
method : 'POST',
url : '/staff/question/api/' + this.id,
data: {
id : 'test',
name : 'sree'
}
})
.then( response => {
console.log(response);
})
.catch(error => {
console.log(error);
})
},
【问题讨论】:
-
controller是什么意思?是symfony吗?像端点? -
是的,处理 POST 请求的端点。