0

I am at witts end with axios/vue currently, hoping someone can see something I am missing.

I am using axios documentation and doing a basic post.

                       axios({
                            method: 'POST',
                            url: 'myurlhere',
                            data: {
                                    firstName: 'Fred',
                                    lastName: 'Flintstone'
                                  },
                            headers: {'Content-Type': 'multipart/form-data' }
                        })
                        .then(function (response) {
                            //handle success
                            console.log(response);
                        })
                        .catch(function (response) {
                            //handle error
                            console.log(response);
                        });

The api is absolutely hit, I am logging it on the server side. The console log on the axios side does not throw any errors. I am printing out the $_REQUEST variable on the server side just to see what is coming through and the $_POST is empty. The console log does show the returned array but post is empty.

<?php
$data=array('worked'=>true,"data"=>$_REQUEST);
echo json_encode($data);
?>

If i use $_GET variables they work. Post does not though. what am I doing wrong???

Trey Tyler
  • 221
  • 2
  • 9
  • What do you see in the browser's Network tab? Does it show the request body correctly formatted? – skirtle Mar 28 '20 at 18:34
  • See https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data – Flame Mar 30 '20 at 14:45

0 Answers0