Is there a way to serializeParams in axios without relying on a 3rd party library such as qs?

Viewed 159

When using the qs library we control how arrays in query parameters would be with option arrayFormat (quote from qs library docs below):

You may use the arrayFormat option to specify the format of the output array:

qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
// 'a[0]=b&a[1]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
// 'a[]=b&a[]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
// 'a=b&a=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })
// 'a=b,c'

Is there a way to define this default array format in axios without having to import the qs library in my project?

1 Answers
Related