Created
April 2, 2020 10:27
-
-
Save midudev/ec535dd1474ec34af4706882047a1107 to your computer and use it in GitHub Desktop.
Transform from querystring to object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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