PHP Post array empty on axios POST

前端 未结 3 1197
迷失自我
迷失自我 2021-02-14 21:54

I\'m trying out Vue 2.0 and axios and I\'ve got a little issue. When I try to send a post request using axios to my post.php file the $_POST array is always empty.

Post

3条回答
  •  囚心锁ツ
    2021-02-14 22:52

    I think you can try this, it should be the data-type problem.

    var data = new FormData();
    data.append('title', 'foo');
    data.append('body', 'bar');
    
    axios.post('api/post.php', data)
        .then(response => {
            console.log(response)
            console.log(response.data)
            this.filter = response.data
        })
        .catch(e => {
            this.errors.push(e)
    });
    

提交回复
热议问题