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

Adding support for params without value. #1987

Merged
merged 4 commits into from Jul 1, 2020
Merged

Adding support for params without value. #1987

merged 4 commits into from Jul 1, 2020

Conversation

vuoriliikaluoma
Copy link

Adds support for params without value when set to null. (test included)
undefined can still be used to exclude the param.

Example:
This params object: { foo: null, bar: "baz", qux: undefined }
Becomes this query string: ?foo&bar=baz

This resolves #1139.

@vuoriliikaluoma
Copy link
Author

Note: Mocha tests weren't working to start with. Tried npm run test before any changes.
I ran the karma tests with .\node_modules\.bin\grunt karma:single and they passed.

lib/helpers/buildURL.js Outdated Show resolved Hide resolved
Copy link

@nickstew nickstew left a comment

Choose a reason for hiding this comment

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

Looks good to me. Minimal change. If not stated in the documentation, this should be expressly stated in the README. Should there be a flag to treat null and undefined as the same? I see each pattern being used in production environments.

@vuoriliikaluoma
Copy link
Author

@nickstew as it is currently; we have full control over the resulting query:
{ key: undefined } to ? (not included)
{ key: null } to ?key
{ key: '' } to ?key=
{ key: 'null' } to ?key=null

@yasuf
Copy link
Collaborator

yasuf commented Nov 18, 2019

this is sort of a breaking change so I'll wait until 0.20.0 or 1.0.0 to release this, probably right after 0.19.1

@yasuf yasuf added the v1.0.0 label Nov 18, 2019
@jasonsaayman jasonsaayman added this to In progress in v1.0.0 via automation May 27, 2020
@jasonsaayman jasonsaayman added this to the v1.0.0 milestone May 27, 2020
@jasonsaayman jasonsaayman changed the base branch from master to release/1.0.0-beta.1 July 1, 2020 17:34
@jasonsaayman jasonsaayman merged commit 49e3059 into axios:release/1.0.0-beta.1 Jul 1, 2020
v1.0.0 automation moved this from In progress to Done Jul 1, 2020
IvanStoilov pushed a commit to IvanStoilov/axios that referenced this pull request Nov 25, 2020
* Added support for params without value. Resolves axios#1139.

* Replaced unnecessary typeof check.

Co-authored-by: Kimmo Liikaluoma <kimmo@oadata.se>
Co-authored-by: Emily Morehouse <emilyemorehouse@gmail.com>
Co-authored-by: Yasu Flores <carlosyasu91@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v1.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

Why are null and undefined variables removed from params
6 participants