Skip to content

HttpClient#post does not serialize native UrlSearchParamsΒ #36317

@thw0rted

Description

@thw0rted

🐞 bug report

Affected Package

The issue is caused by package @angular/common/http

Is this a regression?

I just started using the package so I'm not sure if it worked for previous versions

Description

Passing an instance of browser-native UrlSearchParams as the second argument to HttpClient#post (or as the body option for any request with a body) causes an empty JSON object string "{}" to be used as the body, instead of the correctly serialized URL-encoded form string.

πŸ”¬ Minimal Reproduction

https://angular-issue-repro2-cs1zmj.stackblitz.io

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.3
Node: 12.7.0
OS: win32 x64

Angular: 9.0.2
... common, compiler, core
Ivy Workspace: 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.900.3
@angular-devkit/core         9.0.3
@angular-devkit/schematics   9.0.3
@angular/cli                 9.0.3
@schematics/angular          9.0.3
@schematics/update           0.900.3
rxjs                         6.5.3

Anything else relevant?
I've tested this in latest Edge, Firefox, and Chrome. (IE doesn't support native UrlSearchParams.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: common/httpIssues related to HTTP and HTTP ClientfeatureIssue that requests a new featurehelp wantedAn issue that is suitable for a community contributor (based on its complexity/scope).state: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions