-
-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add accept: application/json header if json option is set #63
Conversation
This should be mentioned in readme too - https://github.com/sindresorhus/got#json |
@@ -55,6 +55,10 @@ function got(url, opts, cb) { | |||
delete opts.timeout; | |||
delete opts.query; | |||
|
|||
if (json && !opts.headers.accept) { | |||
opts.headers.accept = 'application/json'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opts.headers.accept = opts.headers.accept || 'application/json';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean
if (json) {
opts.headers.accept = opts.headers.accept || json && 'application/json';
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to check for json
twice (you're in an if
statement).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course.... sorry, it's accident
lgtm. sqash please. |
Add accept: application/json header if json option is set
Thanks! |
No description provided.