You can use an ajax call, either using the fetch api, axios, or something similar.
Aug 12, 2024
4
Level 1
How can I retrieve data to be shown on a modal and preserve the page state?
I'm building an modal that will retrieve information to be displayed on the own modal, however, when I do a request all my page state is lost even if I set "preserveState" to true.
How can I send a GET request and preserve tha page state?
import { router } from '@inertiajs/vue3'
router.get(`/dashboard/products/store/${ storeSku.value }`, {
preserveState: true,
preserveScroll: true,
only: ['data'],
onSuccess: (data) => {
console.log('-> response from findProductFromStore', data)
},
onError: (err) => {
console.log('-> error from findProductFromStore', err)
}
})
My Controller:
public function find(string $sku)
{
$product = FindProductOnUserStore::run($sku);
abort_unless($product, 404, 'could not find product on user store');
return inertia('Product/Index', [
'data' => $product
]);
}
I've tried using return inertia('Product/Index') and also return back()->with('data, $product)
Please or to participate in this conversation.