/utils/paramString

This module creates a parameter string for an XHR request.

Methods

(inner) paramString(params) → {string}

Creates a parameter string for an XHR request based on the provided parameters object.

The function takes a params object and returns a URL parameter string for for requests.

Following properties are filtered out:

  • Value is falsy and not 0
  • Value is '{}' string.
  • Value is not typeof 'object', empty array, or object with some property value that is an object with keys.

The URL parameter value of objects which are not arrays will be stringified and URI component encoded.

Other property values will be URI encoded.

The URL parameter array is joined with an ampersand (&) to be returned as URL parameter string.

Parameters:
NameTypeDescription
paramsObject

The object containing the parameters.

Returns:

The parameter string.

Type: 
string