Changelog
v0.6.0
Changelog
v0.5.2 2024/7/9
Date
value, call .toISOString()
and utils encodeParams
support options allowDot: true
and arrayFormat: 'indices' | 'repeat' | 'brackets'
(default is 'indices'
). Fix issues/22 and issues/23Code example:
import xior, { encodeParams } from 'xior';
const filter = {
ids: [1, 2, 3],
dateFrom: new Date(),
dateTo: new Date(),
};
const http = xior.create({
paramsSerializer: (params: any) =>
encodeParams(params, true, null, {
allowDots: false,
arrayFormat: 'indices', // 'indices' | 'repeat' | 'brackets'
serializeDate: (date) => date.toISOString(),
}),
});
/*
'indices': { a: ['b', 'c'] } -> 'a[0]=b&a[1]=c'
'brackets': { a: ['b', 'c'] } -> 'a[]=b&a[]=c'
'repeat': { a: ['b', 'c'] } -> 'a=b&a=c'
*/
http.get('https://example.com', { params: { filter } });