1

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?

Lucas Mendonca
  • 387
  • 3
  • 13

1 Answers1

0

You can use paramsSerializer.

For more information, you can see response and comments at https://stackoverflow.com/a/51444749.

  • Hi, that's not exactly what I meant, I'm already using it. My ask is actually if there's a way to change the default serialization without having to pass a function that relies on the qs library. I will edit my question so this is more clear. – Lucas Mendonca Aug 20 '22 at 04:48
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32515991) – Mehan Alavi Aug 24 '22 at 08:29