Created
May 5, 2020 21:13
-
-
Save lyatziv/3c9a1ee94aa47aee4851e338393e2a32 to your computer and use it in GitHub Desktop.
object2qs.js
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
/** | |
* Converts object properties to query string. | |
* @param {object} props - The object used to construct the query string. | |
* @return {string} The query string. | |
*/ | |
export default (props) => { | |
return typeof props === 'object' | |
? `?${Object.keys(props).map((prop) => `${prop}=${props[prop]}`).join('&')}` | |
: '' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment