Created
April 12, 2017 07:28
-
-
Save selbekk/7a55df24c3915502cd6b1064a45b1fde to your computer and use it in GitHub Desktop.
object to query string
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
// 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