Last active
August 12, 2021 05:47
-
-
Save andrew-ma/8bde01013d9a084a9f3637523a6b217e to your computer and use it in GitHub Desktop.
JS object to application/x-www-form-urlencoded content-type
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
/** | |
* @param {Object} object | |
* @return {string} | |
*/ | |
export function toFormUrlEncoded(object) { | |
return Object.entries(object) | |
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) | |
.join('&'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment