0

I have this piece of code in a function called enviar() which will send data to the backend server.

methods: {
  ...
  enviar() {
    this.editable = false

    const form = new FormData();
    form.append('nombre', this.nombre)

    axios.post('http://test.test/test.php', {
      data: this.data,
      _method: 'patch'
    })
  },
  ...

I think it is correct, at least it is according to documentation and this question I read before starting my own.

I have tested so many things, I set up a minimal server (test.test) which has a test.php file which simply is:

POST
<?php print_r($_POST); ?>

GET
<?php print_r($_GET); ?>

I wanted to see if it returns something... and it does!

GET
Array
(
)

POST
Array
(
)

So both $_POST and $_GET are empty arrays. Even if I change the route to http://test.test/test.php?x=whatever the $_GET is still empty

Am I completely doing everything wrong? Am I not getting the point of Axios and whatever?

Brian Lee
  • 17,904
  • 3
  • 41
  • 52
luisfer
  • 1,927
  • 7
  • 40
  • 54
  • https://stackoverflow.com/questions/41457181/axios-posting-params-not-read-by-post can this solve your problem? – Commander Apr 12 '20 at 02:30
  • 1
    It doesn't but there was a link to another question. https://stackoverflow.com/questions/52542123/laravel-vue-js-api-axios-put-method-doesnt-send-any-data-to-controller Unbelievable easy. Anyway, thanks a lot for the heads up! – luisfer Apr 12 '20 at 02:57

0 Answers0