nuxt-community / axios-module

Secure and easy axios integration for Nuxt 2
https://axios.nuxtjs.org
MIT License
1.19k stars 245 forks source link

patch method with FormData() not working #480

Closed jgrandar closed 3 years ago

jgrandar commented 3 years ago

Post method works fine with FormData() but as soon as I try to send the same form with patch method Laravel dd($request->all()) return an empty array.

const respuesta = await this.$axios.$patch(
  `empresas/${this.empresa.id}`,
  formulario,
  { headers: { 'Content-Type': 'multipart/form-data' } }
)
jgrandar commented 3 years ago

Found a solution, it is not an axios-module problem but a Laravel problem https://stackoverflow.com/a/55117171/4228931

Just need to use POST method on axios.

this.$axios.$post()

and add

formulario.append('_method', 'PATCH')

before sending the FormData()