Instantly share code, notes, and snippets.

Embed
What would you like to do?
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