Created
June 28, 2018 17:57
-
-
Save jcypret/e2a29f040799f429f3ee4059d8967ff3 to your computer and use it in GitHub Desktop.
Convert a plain JS object to an encoded query string
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 function objectToQueryString(obj) { | |
return Object.keys(obj) | |
.map(k => encodeURIComponent(k) + "=" + encodeURIComponent(obj[k] || "")) | |
.join("&"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment