Answer the question
In order to leave comments, you need to log in
Why does an error occur when sending a post request: 405 (Method Not Allowed)?
I make a post request, in response I get an error 405 (Method Not Allowed). At the same time, csrf-token backed up too. Interestingly, exactly the same method works fine on another project, but Laravel is a little older there.
bootstrap.js
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
...
getCartData: function (){
return window.axios.post('/show-cart')
.then(response => response.data)
.then(cart => {
this.products = cart['products'];
this.itemsCount = cart['quantity'];
this.cartAmount = cart['amount'];
});
},
...
Auth::routes();
Route::get('/show-cart', 'Admin\[email protected]');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question