Answer the question
In order to leave comments, you need to log in
Error 405 (Method Not Allowed) when making a request via Axios?
The default site language is Russian (shop.local/yarn). Everything works great, no errors. The magic starts when you switch to Ukrainian (shop.local/uk/yarn). The first time you click on the image in the console, an error 405 appears, while if you click again on the same image, the request works, we get the text BUT in Russian, not Ukrainian. What can be wrong?
Update
If change
.post('/details/' + this.dataset.yarn)on the
.post('/uk/details/' + this.dataset.yarn), then it works fine, though it stops working in Russian. Here is the error: prnt.sc/1wzpg2j
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\YarnController;
Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeCookieRedirect', 'localizationRedirect' ]], function() {
Route::post('/details/{slug}', [YarnController::class, 'details'])->name('yarn.details');
});
document.addEventListener('DOMContentLoaded' , () => {
var images = document.querySelectorAll('.img-container');
function getYarnDetails() {
axios
.post('/details/' + this.dataset.yarn)
.then((response) => {
//
});
}
for (var index = 0; index < images.length; index++) {
images[index].addEventListener('click', getYarnDetails);
}
});
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