#Redirect with new Props
1 messages · Page 1 of 1 (latest)
No
A redirect is pretty much a browser thing, it just tells the browser "go to this URL". So you can't pass anything. The only options would be to pass data along with GET parameters, or store data in a session to be used on the next request (flashed session data)
I see thank you Robert, then I will solve this particular case just with an axios.post request
What's the use-case? There's a lot you can do with Inertia without resorting to axios.
I am on the orders.index page and the user can place a order by speaking. I convert his speech to a string (still inside the browser on the frontend) and then I do an form.post to the orders.voice route with that string.
Inside the orders.voice route I convert this string to an JSON object (using an LLM). But because things can go wrong I want the user to confirm what I extracted from his speach before actually saving that order in the DB. So I need to return that json back to the user who is still on the orders.index page and show him an confirmation modal with the JSON i extracted from his input.
While typing this out, I found a solution I think. Instead of posting that form to orders.voice I could just send a post request to the orders.index route and then I would not need an redirect I could just return a Inertia Response with the props
Ah no that would actually not work, because I start this process not from the orders page, the user can actually do this from the dashboard so he is on dashboard route but will post his form to the orders.voice route
Add a modal that shows when you have a param. Pass that param data in via an optional prop.
What do you mean by an optional prop @ivory lark In the controller where I have the data I need to pass in i need to do a redirect back to orders.index and after reading the docs I think it's not possible to pass in props when doing a redirect, as this has nothing to do with a Inertia