Created
March 27, 2014 15:51
-
-
Save VRMink/9810690 to your computer and use it in GitHub Desktop.
Generate GET query from key value pairs with underscore
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 urlFromParams(user){ | |
return _.chain(user) | |
.map( | |
function(value, key){ return encodeURI(key)+'='+encodeURI(value);} | |
) | |
.reduce( | |
function(memo, value){return memo+'&'+value;} | |
).value(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment