Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ToQueryStringOptions

Index

Properties

arraySyntax?: boolean

If true, then nested properties will be encoded by using [] syntax

default

false

example
// foo[]=1&bar[bla]=2
toQueryString({foo: [1], bar: {bla: 2}}, {arraySyntax: true});
encode?: boolean

If false, then the result string won't be encoded by using encodeURIComponent

default

true

separator?: string

Separator for nested properties

default

'_'

example
// foo.bar=1
toQueryString({foo: {bar: 1}}, {separator: '.'});

Methods

  • paramsFilter(value: unknown, key: string, path?: string): unknown
  • Filters values that shouldn't be serialized. By default, the function skip all values with null-s and empty strings.

    example
    // foo=1
    toQueryString({foo: 1, bar: {bla: 2}}, {paramsFilter: (el, key) => key !== 'bla'});

    Parameters

    • value: unknown
    • key: string

      property key

    • Optional path: string

      accumulated property path ({a: {b: 1}} => 'a_b')

    Returns unknown