Skip to content

Instantly share code, notes, and snippets.

@lyatziv
Created May 5, 2020 21:13
Show Gist options
  • Save lyatziv/3c9a1ee94aa47aee4851e338393e2a32 to your computer and use it in GitHub Desktop.
Save lyatziv/3c9a1ee94aa47aee4851e338393e2a32 to your computer and use it in GitHub Desktop.
object2qs.js
/**
* 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