Skip to content

Instantly share code, notes, and snippets.

@wholypantalones
Last active September 11, 2018 14:37
Show Gist options
  • Save wholypantalones/8deb31d01d6fc8e4c13d618398d5c77a to your computer and use it in GitHub Desktop.
Save wholypantalones/8deb31d01d6fc8e4c13d618398d5c77a to your computer and use it in GitHub Desktop.
Params obj from config block
config = {
page: 0,
pageSize: 25,
sortColumn: 'publishDate',
sortDirection: 'ASC'
};
/**
* loop through the config block and delete the things we do not need
* to make a params obj from the config obj
*/
objFromConfig(obj) {
const newObj = JSON.parse(JSON.stringify(obj));
Object.entries(newObj).map(([k, v]) => {
if (v === null || v === '') {
delete newObj[k];
}
});
return newObj;
}
// usage: params = this.objFromConfig(config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment