Skip to content

Adding support for params without value.#1987

Merged
jasonsaayman merged 4 commits into
release/1.0.0-beta.1from
unknown repository
Jul 1, 2020
Merged

Adding support for params without value.#1987
jasonsaayman merged 4 commits into
release/1.0.0-beta.1from
unknown repository

Conversation

@ghost

@ghost ghost commented Feb 1, 2019

Copy link
Copy Markdown

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.

@ghost

ghost commented Feb 1, 2019

Copy link
Copy Markdown
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.

Comment thread lib/helpers/buildURL.js Outdated

@nickstew nickstew left a comment

Copy link
Copy Markdown

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.

@ghost

ghost commented Feb 6, 2019

Copy link
Copy Markdown
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

yasuf commented Nov 18, 2019

Copy link
Copy Markdown
Contributor

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

None yet

Development

Successfully merging this pull request may close these issues.

Why are null and undefined variables removed from params

5 participants