Answers for "add query params to an existing url javascript"

0

add url query in js

const urlParams = new URLSearchParams(window.location.search);

urlParams.set('order', 'date');

window.location.search = urlParams;
Posted by: Guest on October-14-2021
0

js add query param

function setParam(uri, key, val) {
    return uri
        .replace(RegExp("([?&]"+key+"(?=[=&#]|$)[^#&]*|(?=#|$))"), "&"+key+"="+encodeURIComponent(val))
        .replace(/^([^?&]+)&/, "$1?");
}
Posted by: Guest on November-21-2020

Code answers related to "add query params to an existing url javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language