1var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
1function objectToQueryString(obj) {
2 var str = [];
3 for (var p in obj)
4 if (obj.hasOwnProperty(p)) {
5 str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
6 }
7 return str.join("&");
8}
9
10var person = { first_name : "Marty",last_name : "Mcfly"};
11var queryString=objectToQueryString(person); //"first_name=Marty&last_name=Mcfly"
1 const queryString = new URLSearchParams(props.location.search);
2//or
3var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
4//Extracting query String key value pairs
5for (let param of queryString.entries()) {
6 console.log(param);
7}