Skip to content

Instantly share code, notes, and snippets.

@Dammic
Created November 7, 2017 18:01
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 Dammic/60bff65488210f559fe2d382c6955ca4 to your computer and use it in GitHub Desktop.
Save Dammic/60bff65488210f559fe2d382c6955ca4 to your computer and use it in GitHub Desktop.
Query
function buildQueryString(args){
const argsArray = Object
.entries(args)
.filter(([key, value]) => value !== undefined);
if (!argsArray.length) return '';
return `?${argsArray
.map(([key, value]) => `${key}=${value}`)
.join('&')
}`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment