Answers for "how to take the query string and convert it to object in javascript"

2

js object to querystring

const params = {foo:"Hi", bar:"there"}
const queryString = new URLSearchParams(params).toString();

console.log(queryString);
Posted by: Guest on January-05-2021
1

javascript urlsearchparams to object

var search = location.search.substring(1);
JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}')
Posted by: Guest on September-23-2020

Code answers related to "how to take the query string and convert it to object in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language