Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Remove 'debug' option from listLog opts #254

Merged
merged 2 commits into from
Feb 28, 2018
Merged

Conversation

codebycaleb
Copy link
Contributor

Requests to /api/platform/cli/apps/{id}/logs?debug=true result in an error complaining about the 'debug' parameter. This commit will remove any 'debug' opt before sending the request to the logs api.

I'm not a JavaScript expert, so I went to the internet for help regarding cloning objects and removing properties from objects. I hope I did this the way others would (I didn't want to delete the 'debug' opt from the original object; I just wanted to remove it before sending the api request).

Requests to /api/platform/cli/apps/{id}/logs?debug=true result in an
error complaining about the 'debug' parameter. This commit will remove
any 'debug' opt before sending the request to the logs api.
@xavdid xavdid self-requested a review February 27, 2018 04:39
Copy link
Contributor

@xavdid xavdid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Great job considering how to not modify the incoming object.

We can shrink that code down though. We use a library called lodash, which is like a swiss army knife of a bunch of awesome functions.

One such function is omit (docs), which returns a copy of an object sans whichever keys you supply. So, you can do the following:

const cleaned = _.omit(opts, 'debug')

and honestly, just drop that into the stringify call. One and done!

Converts my previous 3-line approach into an easy-to-read 1-liner!
@codebycaleb
Copy link
Contributor Author

@xavdid Thanks for that! lodash looks awesome – it was even listed in the StackOverflow I originally referenced for removing a key immutably, but I didn't think to check if we used it. I've updated my code accordingly. Thanks for the snippit too!

@xavdid
Copy link
Contributor

xavdid commented Feb 28, 2018

cool, feel free to merge at your leisure! it'll get deployed when the next version goes out, whenever that is.

@codebycaleb codebycaleb merged commit 80834c6 into master Feb 28, 2018
@codebycaleb codebycaleb deleted the clean-listlog-opts branch February 28, 2018 12:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants