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

vincent15000's avatar

Inertia::post() and Inertia::put() => datas always in URL ?

Hello,

Using Inertia::post() and Inertia::put(), are the datas always passed as URL paramaters ?

With POST and PUT methods, it's usually suggested (as a best pratice) to pass the params in the body of the request and not in the URL.

Would InertiaJS not respect the best pratices ?

Or perhaps I have something wrong in my code ...

Thanks for your answer ;).

Vincent

0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Sounds like you are passing the data to route() instead of post(). If in doubt show an example that doesn't work

Inertia.post(route('foo', data)); //data goes in url
Inertia.post(route('foo'), data); //data goes in body 
1 like
vincent15000's avatar

@Sinnbeck route(...) is the Ziggy route method.

I have this.

Inertia.put(route('states.update', props.state), {
  data: { state: props.state.id }
})

Like this it works ;).

Inertia.put(route('states.update', props.state.id), props.state)

Please or to participate in this conversation.