Created
August 18, 2020 03:33
-
-
Save codeyourwayup/cbb7e7063f9fd9247d19325af4284b88 to your computer and use it in GitHub Desktop.
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
const objectToQueryString = queryParameters => { | |
return queryParameters | |
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => { | |
const symbol = queryString.length === 0 ? '?' : '&'; | |
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : ''; | |
return queryString; | |
}, '') | |
: ''; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment