小编Pra*_*esh的帖子

使用axios不发送参数的POST请求

我试图使用以下代码将一些数据从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)

symfony vue.js axios

2
推荐指数
2
解决办法
5317
查看次数

标签 统计

axios ×1

symfony ×1

vue.js ×1