Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert object to query parameters
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
You can’t perform that action at this time.