Created
April 15, 2019 17:25
-
-
Save ahkohd/92c3dedb01e04c58cd1f9d0a229136a2 to your computer and use it in GitHub Desktop.
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
function ObjectToUrlEncode(data) | |
{ | |
return Object.entries(data).reduce((accumulator, current) => { | |
return `${accumulator}&${current[0]}=${current[1]}`; | |
}, '').substring(1); | |
} | |
console.log(ObjectToUrlEncode({name: "victor", age: 12, line: 13})); | |
// OUTPUT: "name=victor&age=12&line=13" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A simple snippet that converts Javascript object to URL-Encode. A JSBin example
https://jsbin.com/soqifeyavo/edit?html,js,console,output