Skip to content

Instantly share code, notes, and snippets.

@olizilla
Created December 21, 2016 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olizilla/9bc8aba859f21c2f2c1a70a9b4431730 to your computer and use it in GitHub Desktop.
Save olizilla/9bc8aba859f21c2f2c1a70a9b4431730 to your computer and use it in GitHub Desktop.
Minimal object to query string function
function queryify (obj) {
const pairs = Object.keys(obj).map((k) => {
const key = encodeURIComponent(k)
const val = encodeURIComponent(obj[k])
return key + '=' + val
})
return '?' + pairs.join('&')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment