Skip to content

Instantly share code, notes, and snippets.

@selbekk
Created April 12, 2017 07:28
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 selbekk/7a55df24c3915502cd6b1064a45b1fde to your computer and use it in GitHub Desktop.
Save selbekk/7a55df24c3915502cd6b1064a45b1fde to your computer and use it in GitHub Desktop.
object to query string
// Implementation
const toQueryString = params => Object.entries(params)
.map((param) => param.join('='))
.join('&');
// Example usage
const qs = toQueryString({ apiKey: 'secret', page: 2 });
qs === 'apiKey=secret&page=2'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment