Skip to content

Instantly share code, notes, and snippets.

@VRMink
Created March 27, 2014 15:51
Show Gist options
  • Save VRMink/9810690 to your computer and use it in GitHub Desktop.
Save VRMink/9810690 to your computer and use it in GitHub Desktop.
Generate GET query from key value pairs with underscore
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