Skip to content

Instantly share code, notes, and snippets.

@xiekw2010
Created January 19, 2017 08:46
Show Gist options
  • Save xiekw2010/7d36ed5a46063e2c69b9c45ab230bdf3 to your computer and use it in GitHub Desktop.
Save xiekw2010/7d36ed5a46063e2c69b9c45ab230bdf3 to your computer and use it in GitHub Desktop.
object to query string
function object2QueryString(obj) {
let queryString = ''
if (Object.keys(obj).length) {
queryString = Object
.keys(obj)
.map(k => k + '=' + obj[k])
.reduce((a, b) => a + '&' + b, '')
}
return queryString.slice(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment