Created
December 21, 2016 11:29
-
-
Save olizilla/9bc8aba859f21c2f2c1a70a9b4431730 to your computer and use it in GitHub Desktop.
Minimal object to query string function
This file contains 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
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