Skip to content

Documentation / @ember-data/request-utils / index / sortQueryParams

ts
function sortQueryParams(params, options?): URLSearchParams;

Defined in: index.ts:473

Sorts query params by both key and value returning a new URLSearchParams object with the keys inserted in sorted order.

Treats included specially, splicing it into an array if it is a string and sorting the array.

Options:

  • arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'

'bracket': appends [] to the key for every value e.g. &ids[]=1&ids[]=2 'indices': appends [i] to the key for every value e.g. &ids[0]=1&ids[1]=2 'repeat': appends the key for every value e.g. &ids=1&ids=2 'comma' (default): appends the key once with a comma separated list of values e.g. &ids=1,2

Parameters

params

QueryParamsSource

options?

QueryParamsSerializationOptions

Returns

URLSearchParams

A URLSearchParams with keys inserted in sorted order

Released under the MIT License.