Last active
July 16, 2017 19:56
-
-
Save eperedo/f67644786d307e478a704f4658ed4343 to your computer and use it in GitHub Desktop.
Convert object to query parameters
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 objectToQuery(obj, notInclude = []){ | |
const keys = Object.keys(obj); | |
const keysToConvert = keys.filter((kf) => { | |
return notInclude.indexOf(kf) === -1; | |
}) | |
const qs = keysToConvert.map((key) => { | |
const currentKey = obj[key]; | |
return `&${key}=${currentKey}`; | |
}); | |
return qs.join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment