Skip to content

Instantly share code, notes, and snippets.

@sethdavis512
Created August 18, 2022 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethdavis512/2b39e809ba181c191abee25b034096ae to your computer and use it in GitHub Desktop.
Save sethdavis512/2b39e809ba181c191abee25b034096ae to your computer and use it in GitHub Desktop.
const encodeGetParams = p =>
Object.entries(p).map(kv => kv.map(encodeURIComponent).join("=")).join("&");
const params = {
user: "María Rodríguez",
awesome: true,
awesomeness: 64,
"ZOMG+&=*(": "*^%*GMOZ"
};
console.log("https://example.com/endpoint?" + encodeGetParams(params))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment