How to preserve current GET url in the browser while making POST request to server in Laravel-8 and InertiaJs
Asked Answered
J

2

6

I am using Inertia JS in Laravel 8, with following POST request to server. The problem is that the browser URL is also updated with POST request, which may be a expected behavior in some cases but I want to keep the actual GET request in the browser despite sending different types of requests to server using multiple Laravel routes.

this.$inertia.put(`/task/${task_id}`, {order, category_id});

this.$inertia.visit(`/task/${task_id}`, {
    method: 'put',
    data: {order, category_id},
    only: ['categories', 'msg'],
    replace: true,
    preserveState: true,
    preserveScroll: true,
});
                

Does anybody have the idea, how I can preserve existing GET URL in the browser while send POST requests to server using Inertia JS?

Johannejohannes answered 21/12, 2020 at 16:37 Comment(1)
Did you find and solution?Flummox
G
3

in your task controller, use return Redirect::route('your_original_route');

Groundsheet answered 6/4, 2022 at 3:19 Comment(1)
Example for your case it may look like something like this: return Redirect::route('task', [$task])Beefy
G
1

you can try remove the replace: true

Greenstein answered 17/11, 2021 at 12:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.