[Vuejs]-How can I using put method to update data on the vue component?

5👍

Laravel uses method spoofing for PUT, use axios.post and add the following to your requests data:

data: {
    ...
    _method: 'PUT',
    ...
}

You can do:

formData.append('_method', 'PUT')

Complete example using axios:

axios.post('/user', { _method: 'PUT', foo: 'bar' })
  .then(function (response) { console.log(response); })
  .catch(function (error) { console.log(error); });

Form method spoofing

Leave a comment