Skip to content
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

Merged
merged 1 commit into from
May 8, 2015

Conversation

km256
Copy link
Contributor

@km256 km256 commented May 8, 2015

No description provided.

@floatdrop
Copy link
Contributor

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';
Copy link
Contributor

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';

Copy link
Contributor Author

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';
}

?

Copy link
Contributor

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).

Copy link
Contributor Author

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

@floatdrop
Copy link
Contributor

lgtm. sqash please.

floatdrop added a commit that referenced this pull request May 8, 2015
Add accept: application/json header if json option is set
@floatdrop floatdrop merged commit 03a5302 into sindresorhus:master May 8, 2015
@floatdrop
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants