2

Hi everyone POST and GET methods are working on my application, but PATCH method don't. On my WAMP server everything works fine. On VPS server - don't. I get 405 Method not allowed.

I am using: Laravel 5.4, Vue.js 2.

Patch method:

axios.patch('/profile/' + this.profile.id + '/update', this.overview)
.then(resp => {
    this.successDataSave(resp.data)
})

Route:

Route::patch('/profile/{profile}/update', 'AppController@update');

EDIT: PATCH method doesnt work only on axios, if I use patch route on html form, with {{ method_field('PATCH') }} it works.

varov
  • 21
  • 1
  • 5
  • see CORS preflight request : http://stackoverflow.com/questions/42137354/axios-call-api-with-get-become-options/42141696#42141696 – Happyriri Apr 04 '17 at 11:46

2 Answers2

2

Using {{ method_field('PATCH') }} generates the following html: <input type="hidden" name="_method" value="PUT">

So try set: this.overview._method = "PUT"

And then do a post:

axios.post('/profile/' + this.profile.id + '/update', this.overview)
    .then(resp => {
        this.successDataSave(resp.data)
})
0

Replace your route with following route that use for all CRUD opration:

Route::resource('/profile', 'AppController@update');

and you can check the docs for more information

resourceController

ramzi trabelsi
  • 842
  • 2
  • 8
  • 18