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.

1

2 Answers 2

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)
})
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.