Answers for "how get query string in javascript"

3

get query param javascript

const urlParams = new URLSearchParams(window.location.search);
const myParam = urlParams.get('myParam');
Posted by: Guest on November-18-2020
0

string to query string javascript

serialize = function(obj) {
  var str = [];
  for (var p in obj)
    if (obj.hasOwnProperty(p)) {
      str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
    }
  return str.join("&");
}

console.log(serialize({
  foo: "hi there",
  bar: "100%"
}));
// foo=hi%20there&bar=100%25
Posted by: Guest on March-27-2020

Code answers related to "how get query string in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language