我试图使用以下代码将一些数据从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);
})
},
Run Code Online (Sandbox Code Playgroud)
但是,我附加到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);
})
},
Run Code Online (Sandbox Code Playgroud)