qs
qs copied to clipboard
How can you keep the square brackets when using arrayFormat: comma
With the following code
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })
// 'a=b,c'
plus some option, I want to obtain a result that looks like
// 'a=[b,c]'
How can I do this?
That’s not the comma format, so I’m not sure how you can.
What server expects that format??
That’s not the comma format, so I’m not sure how you can.
well it doesn't need to be the comma format then, but it needs to be that format
What server expects that format??
oof, so binance basically just invented their own format instead of using the universal ones that already exist?
I'm not sure how to do that with qs; perhaps with a custom encoder?
You can use filter.
qs.stringify(params, {
filter: (prefix, value) => {
if (Array.isArray(value)) return `[${value.join(',')}]`
return value
},
})