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

AxiosHeaders toJSON #5680

Open
askmewhat opened this issue Apr 27, 2023 · 1 comment
Open

AxiosHeaders toJSON #5680

askmewhat opened this issue Apr 27, 2023 · 1 comment

Comments

@askmewhat
Copy link

Describe the bug

The judgment of "value !== false" inside the toJSON method of the AxiosHeaders class, is it necessary? If I add a header with a value of false, it will be automatically deleted. Is this reasonable?

To Reproduce

No response

Code snippet

utils.forEach(this, (value, header) => {
      value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
    });

Expected behavior

Remove the judgment of "value !== false".

Axios Version

1.x

Adapter Version

xhr

Browser

Chrome

Browser Version

112.0.5615.138

Node.js Version

16.20.0

OS

Win 11

Additional Library Versions

No response

Additional context/Screenshots

No response

@DigitalBrainJS
Copy link
Collaborator

DigitalBrainJS commented Sep 27, 2023

Yes, the false value is taken into account by the set method and its rewrite option in the AxiosHeader API. Therefore, such a value will not be overwritten unless the rewrite option is explicitly specified in the method. Axios logic relies on this to allow the user to opt out of installing unwanted and/or default headers.

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

No branches or pull requests

4 participants