HttpParams

From Get docs
< @angular/common‎ | httpAngular/docs/8/api/common/http/httpparams


HttpParams

class

An HTTP request/response body that represents serialized parameters, per the MIME type application/x-www-form-urlencoded.

See more...

class HttpParams {
  constructor(options: HttpParamsOptions = {} as HttpParamsOptions)
  has(param: string): boolean
  get(param: string): string | null
  getAll(param: string): string[] | null
  keys(): string[]
  append(param: string, value: string): HttpParams
  set(param: string, value: string): HttpParams
  delete(param: string, value?: string): HttpParams
  toString(): string
}

Description

This class is immutable; all mutation operations return a new instance.

Constructor

constructor(options: HttpParamsOptions = {} as HttpParamsOptions)

Parameters
options HttpParamsOptions Optional. Default is {} as HttpParamsOptions.


Methods

Reports whether the body includes one or more values for a given parameter.

has(param: string): boolean

Parameters
param string The parameter name.
Returns

boolean: True if the parameter has one or more values, false if it has no value or is not present.


Retrieves the first value for a parameter.

get(param: string): string | null

Parameters
param string The parameter name.
Returns

string | null: The first value of the given parameter, or null if the parameter is not present.


Retrieves all values for a parameter.

getAll(param: string): string[] | null

Parameters
param string The parameter name.
Returns

string[] | null: All values in a string array, or null if the parameter not present.


Retrieves all the parameters for this body.

keys(): string[]

Parameters

There are no parameters.

Returns

string[]: The parameter names in a string array.


Appends a new value to existing values for a parameter.

append(param: string, value: string): HttpParams

Parameters
param string The parameter name.
value string The new value to add.
Returns

HttpParams: A new body with the appended value.


Replaces the value for a parameter.

set(param: string, value: string): HttpParams

Parameters
param string The parameter name.
value string The new value.
Returns

HttpParams: A new body with the new value.


Removes a given value or all values from a parameter.

delete(param: string, value?: string): HttpParams

Parameters
param string The parameter name.
value string

The value to remove, if provided.

Optional. Default is undefined.

Returns

HttpParams: A new body with the given value removed, or with all values removed if no value is specified.


Serializes the body to an encoded string, where key-value pairs (separated by =) are separated by &s.

toString(): string

Parameters

There are no parameters.

Returns

string



© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v8.angular.io/api/common/http/HttpParams