Edit this page

API class up.Params

The up.Params class offers a consistent API to read and manipulate request parameters independent of their type.

Request parameters are used in form submissions and URLs. Methods like up.submit() or up.replace() accept request parameters as a { params } option.

Supported parameter types

The following types of parameter representation are supported:

  1. An object like { email: 'foo@bar.com' }
  2. A query string like 'email=foo%40bar.com'
  3. An array of { name, value } objects like [{ name: 'email', value: 'foo@bar.com' }]
  4. A FormData object.

All features

JS
new up.Params([params]) experimental

Constructs a new up.Params instance.

JS
up.Params.fromFields(fields) experimental

Constructs a new up.Params instance from one or more HTML form field.

JS
up.Params.fromForm(form) experimental

Constructs a new up.Params instance from the given <form>.

JS
up.Params.fromURL(url) experimental

Constructs a new up.Params instance from the given URL's query string.

JS
up.Params.prototype.add(name, value) experimental

Adds a new entry with the given name and value.

JS
up.Params.prototype.addAll(params) experimental

Adds all entries from the given list of params.

JS
up.Params.prototype.addField(field) experimental

Adds params from the given HTML form field.

JS
up.Params.prototype.clear() experimental

Removes all params from this object.

JS
up.Params.prototype.delete(name) experimental

Deletes all entries with the given name.

JS
up.Params.prototype.get(name) experimental

Returns the first param value with the given name from the given params.

JS
up.Params.prototype.getAll(name) experimental

Returns an array of all param values with the given name.

JS
up.Params.prototype.getFirst(name) experimental

Returns the first param value with the given name.

JS
up.Params.prototype.set(name, value) experimental

Sets the value for the entry with given name.

JS
up.Params.prototype.toArray() experimental

Returns an array representation of this up.Params instance.

JS
up.Params.prototype.toFormData() experimental

Returns a FormData representation of this up.Params instance.

JS
up.Params.prototype.toObject() experimental

Returns an object representation of this up.Params instance.

JS
up.Params.prototype.toQuery(params) experimental

Returns an query string for this up.Params instance.

JS
up.Params.prototype.toURL(base) experimental

Builds an URL string from the given base URL and this up.Params instance as a query string.

JS
up.Params.stripURL(url) experimental

Returns the given URL without its query string.