The URLSearchParams API provides read and write access to the query of a URL.
The URLSearchParams class can also be used standalone with one of the four following constructors.
The URLSearchParams class is also available on the global object.
The WHATWG URLSearchParams interface and the querystring module have similar purpose,
but the purpose of the querystring module is more general, as it allows the customization of delimiter characters (& and =`). On the other hand, this API is designed purely for URL query strings.
Constructor
Methods
forEach(fn:(value:String, name:String, searchParams:URLSearchParams) ‑> Void, ?thisArg:Dynamic):Void
forEach(fn:(value:String) ‑> Void, ?thisArg:Dynamic):Void
forEach(fn:(value:String, name:String) ‑> Void, ?thisArg:Dynamic):Void
Iterates over each name-value pair in the query and invokes the given function.
get(name:String):String
Returns the value of the first name-value pair whose name is name.
If there are no such pairs, null is returned.
getAll(name:String):Array<String>
Returns the values of all name-value pairs whose name is name.
If there are no such pairs, an empty array is returned.
set(name:String, value:String):Void
Sets the value in the URLSearchParams object associated with name to value.
If there are any pre-existing name-value pairs whose names are name, set the first such pair's value to value and remove all others.
If not, append the name-value pair to the query string.
sort():Void
Sort all existing name-value pairs in-place by their names. Sorting is done with a stable sorting algorithm, so relative order between name-value pairs with the same name is preserved.
This method can be used, in particular, to increase cache hits.