fix(common): allow number or boolean as http params by cexbrayat · Pull Request #40663 · angular/angular
PR Checklist
Please check if your PR fulfills the following requirements:
- The commit message follows our guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit
- Tests for the changes have been added (for bug fixes / features)
- Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
- Bugfix
- Feature
- Code style update (formatting, local variables)
- Refactoring (no functional changes, no api changes)
- Build related changes
- CI related changes
- Documentation content changes
- angular.io application / infrastructure changes
- Other... Please describe:
What is the current behavior?
Currently, the HTTP client expects string values for parameters, forcing us to cast numbers or boolean.
For example, if page is a number, we have to do something like:
this.http.get('/api/config', { params: { page: `${page}` } });
Issue Number: #23856 (but does not address the Date part of the issue)
What is the new behavior?
Allows to use number and boolean directly as HTTP params, instead of having to convert it to string first.
this.http.get('/api/config', { params: { page }});
HttpParams has also been updated to have most of its methods accept number or boolean values.
Does this PR introduce a breaking change?
- Yes
- No