Created
December 5, 2016 20:37
-
-
Save raphaelpor/d04dc1d10f89c3caf0ed90ab026293c0 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
export default function transformParams(source) { | |
if (source) { | |
const params = Object.entries(source); | |
const paramsList = []; | |
params.forEach((item) => { | |
const key = encodeURIComponent(item[0]); | |
const value = encodeURIComponent(item[1]); | |
paramsList.push(`${key}=${value}`); | |
}); | |
return paramsList.length ? `?${paramsList.join('&')}` : ''; | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment