Obtenha parâmetros de consulta URL JS
const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');
Embarrassed Elephant
const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
const { search } = useLocation()
const redireactURL = new URLSearchParams(search).get('redirect')
const redirect = redireactURL ? redireactURL : '/'
---------------------
/*
const params = new URLSearchParams(window. location. search)
params. has('test')
params. get('test')
const params = new URLSearchParams(window. location. search) for (const param of params) { console. log(param) }
*/