Answers for "javascript query string to object URLSearchParams"

2

javascript reading query parameter

// example url: https://mydomain.com/?fname=johnny&lname=depp
const urlParams = new URLSearchParams(window.location.search);
const firstName = urlParams.get('fname'); // johnny
Posted by: Guest on September-18-2020
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 "javascript query string to object URLSearchParams"

Code answers related to "Javascript"

Browse Popular Code Answers by Language