Skip to content

Instantly share code, notes, and snippets.

@midudev
Created April 2, 2020 10:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midudev/ec535dd1474ec34af4706882047a1107 to your computer and use it in GitHub Desktop.
Save midudev/ec535dd1474ec34af4706882047a1107 to your computer and use it in GitHub Desktop.
Transform from querystring to object
// get the querystring from document object
const qs = document.location.search
// create searchParams object
const searchParams = new URLSearchParams(qs)
// create a plain object using entries
const queryParamsObject = Object.fromEntries(searchParams.entries())
console.log(queryParamsObject)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment