Skip to content

Instantly share code, notes, and snippets.

@eperedo
Last active July 16, 2017 19:56
Show Gist options
  • Save eperedo/f67644786d307e478a704f4658ed4343 to your computer and use it in GitHub Desktop.
Save eperedo/f67644786d307e478a704f4658ed4343 to your computer and use it in GitHub Desktop.
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