swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Axios: array param

Open mikepiven opened this issue 4 years ago • 3 comments
trafficstars

A fix is ​​needed to convert arrays to query parameters. Now, instead of a similar site.io/request?id=100&id=200 it is done like this site.io/request?id[]=100&id[]=200

mikepiven avatar Sep 29 '21 12:09 mikepiven

this could be achieved with https://github.com/ljharb/qs you can pass this to requestParams (the last argument)

{
    paramsSerializer: params =>
      qs.stringify(params, { arrayFormat: 'brackets' }),
},

see more options: image

ApacheEx avatar Sep 30 '21 21:09 ApacheEx

Axios

I have the same problem , when use array parameters

image

sudongyuer avatar Nov 01 '21 08:11 sudongyuer

Thanks @ApacheEx, paramsSerializer helps with that (I'm using indices in my case)

indapublic avatar Sep 10 '22 02:09 indapublic

This worked for me:

 {
     paramsSerializer: {
          indexes: null,
    },
}

kulbon avatar Nov 08 '22 10:11 kulbon