How to add new parameter to URL in JavaScript

2 Answers

0 votes
const URL = new URLSearchParams("http://seek4info.com/search.php?q=hosting&total=10&size=25k");
  
URL.append('size', '10k');

console.log(URL.getAll('size'));
  
  
    
      
/*
run:
      
["25k", "10k"]
      
*/

 



answered Jan 31, 2021 by avibootz
0 votes
const URL = new URLSearchParams("http://seek4info.com/search.php?q=hosting&total=10&size=25k");
  
URL.append('time', '2s');

console.log(URL.toString());
  
  
    
      
/*
run:
      
"http%3A%2F%2Fseek4info.com%2Fsearch.php%3Fq=hosting&total=10&size=25k&time=2s"
      
*/

 



answered Jan 31, 2021 by avibootz
...