Skip to content

Commit 91cdc11

Browse files
cexbrayatzarend
authored andcommitted
fix(common): allow number or boolean as http params (#40663)
This change fixes an incompatibility between the old `@angular/http` package and its successor (`@angular/common/http`) by re-introducing the types that were supported before. It now allows to use number and boolean directly as HTTP params, instead of having to convert it to string first. Before: this.http.get('/api/config', { params: { page: `${page}` } }); After: this.http.get('/api/config', { params: { page }}); `HttpParams` has also been updated to have most of its methods accept number or boolean values. Fixes #23856 BREAKING CHANGE: The methods of the `HttpParams` class now accept `string | number | boolean` instead of `string` for the value of a parameter. If you extended this class in your application, you'll have to update the signatures of your methods to reflect these changes. PR Close #40663
1 parent 383d226 commit 91cdc11

File tree

6 files changed

+529
-272
lines changed

6 files changed

+529
-272
lines changed

aio/content/guide/http.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The `get()` method takes two arguments; the endpoint URL from which to fetch, an
7272
options: {
7373
headers?: HttpHeaders | {[header: string]: string | string[]},
7474
observe?: 'body' | 'events' | 'response',
75-
params?: HttpParams|{[param: string]: string | string[]},
75+
params?: HttpParams|{[param: string]: string | number | boolean | ReadonlyArray<string | number | boolean>},
7676
reportProgress?: boolean,
7777
responseType?: 'arraybuffer'|'blob'|'json'|'text',
7878
withCredentials?: boolean,

0 commit comments

Comments
 (0)