In which way can I in laravel 10 / inertiajs 3 app get value of current page, whe using pagination and url like :
http://127.0.0.1:8000/?page=3'
?
I tried window.location
- has data:
href: 'http://127.0.0.1:8000/?page=3', origin: 'http://127.0.0.1:8000', protocol: 'http:', host: '127.0.0.1:8000', …}
and window.location.href
:
http://127.0.0.1:8000/?page=3
I mean without parsing string value...
You can achieve this in two ways:
const page = new URLSearchParams(window.location.search).get('page');
console.log(page); // "3"
import { router } from '@inertiajs/vue3';
const page = router.page.props.query?.page;
console.log(page); // "3"