class URLSearchParams

Supported only in the v8 engine. Introduced in Max v9.2.0.

Reads and manipulates URL query strings.

Example

const params = new URLSearchParams("a=1&b=2");
params.append("a", "3");
post(params.getAll("a").join(","), "\n"); // 1,3
post(params.toString(), "\n"); // a=1&b=2&a=3

Index

Constructors

Methods

new URLSearchParams(init)

new URLSearchParams(
  init?: string | URLSearchParams | string[][] | Record<string, string>,
);

Constructs a new instance of the URLSearchParams class

ParameterTypeDescription
optional initstring | URLSearchParams | string[][] | Record<string, string>initial values: a query string, another URLSearchParams, an array of [name, value] pairs, or a record of string values.

append(name, value)

Appends a new name/value pair.

append(name: string, value: string): void;
NameTypeDescription
namestring
valuestring

delete(name)

Removes all values for a name.

delete(name: string): void;
NameTypeDescription
namestring

entries()

Iterates [name, value] pairs.

entries(): IterableIterator<[string, string]>;
NameTypeDescription
Return ValueIterableIterator<[string, string]>

get(name)

Returns the first value for a name, or null.

get(name: string): string | null;
NameTypeDescription
namestring
Return Valuestring | null

getAll(name)

Returns all values for a name.

getAll(name: string): string[];
NameTypeDescription
namestring
Return Valuestring[]

has(name)

Returns whether any value exists for a name.

has(name: string): boolean;
NameTypeDescription
namestring
Return Valueboolean

keys()

Iterates parameter names.

keys(): IterableIterator<string>;
NameTypeDescription
Return ValueIterableIterator<string>

set(name, value)

Sets a name to a single value, replacing any existing values.

set(name: string, value: string): void;
NameTypeDescription
namestring
valuestring

toString()

Serializes the parameters to a query string (without a leading ?).

toString(): string;
NameTypeDescription
Return Valuestring

values()

Iterates parameter values.

values(): IterableIterator<string>;
NameTypeDescription
Return ValueIterableIterator<string>