Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laravel_beginner's avatar

Using wildcard in vue.js script

I want to ask how to use wildcard in a script of vue.js. I thought something like this.

axios.patch("/package/" + this.id + "/update"

but I am getting an error

PATCH http://127.0.0.1:8000/edit_package/17 405 (Method Not Allowed)

, which I think is because of this. In a template, I would just do it like this

"`/package/${this.id}/update`"

, but in a script, it doesn't work. Please how can I do this?

0 likes
5 replies
pkboom's avatar

Method Not Allowed means the method is not right. You use patch here. But in your route file, it might've been implemented with a different method like 'put'.

laravel_beginner's avatar

@pkboom But it isn't. I thought about that kind of mistake. My route looks like this

Route::patch("/package/{id}/update", [\App\Http\Controllers\ProductController::class, "updatePackage"])->name("package_update");
pkboom's avatar

@laravel_beginner edit_package/17 405 (Method Not Allowed) and /package/{id}/update. They are different urls. Your error doesn't come from the latter.

Ben Taylor's avatar
Level 35

You need to use post from axios and the pass the patch as part of the data.

{
__method: 'PATCH'
}
1 like

Please or to participate in this conversation.