Created
September 28, 2018 12:13
-
-
Save avkosme/a1be947ebfa3ce8c2b722508db2d7f9f to your computer and use it in GitHub Desktop.
toQueryString
This file contains hidden or 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
export const toQueryString = (params) => { | |
if (!params) { | |
return '' | |
} | |
if (!Object.keys(params).length) { | |
return '' | |
} | |
return '?' + Object | |
.keys(params) | |
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`) | |
.join('&') | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment