Skip to content

Instantly share code, notes, and snippets.

@CreatiCoding
Created April 18, 2019 11:33
Show Gist options
  • Select an option

  • Save CreatiCoding/f1d2717e062810c7aaad6d031c837265 to your computer and use it in GitHub Desktop.

Select an option

Save CreatiCoding/f1d2717e062810c7aaad6d031c837265 to your computer and use it in GitHub Desktop.
query string to query object
const queryStr2queryObj =
(queryStr) => queryStr !== ''
? queryStr
.split('&')
.map((e) => ({ [e.split('=')[0]]: e.split('=')[1] }))
.reduce((a, c) => {
return { ...a, ...c };
})
: {};
@CreatiCoding

Copy link
Copy Markdown
Author

끄앍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment